Skip to content

Reworked Geomag#3

Open
todd-dembrey wants to merge 23 commits into
cmweiss:masterfrom
todd-dembrey:master
Open

Reworked Geomag#3
todd-dembrey wants to merge 23 commits into
cmweiss:masterfrom
todd-dembrey:master

Conversation

@todd-dembrey

Copy link
Copy Markdown

Major rework, changes include:

  • rewrite of method
  • change of names to better reflect process
  • creation of documentation
  • additional testing
  • example

Works with both 2/3 python and backwards compatible.

Happy to discuss further changes if required?

Major rework, changes include:
	rewrite of method
	change of names to better reflect process
	creation of documentation
	additional testing
	example
Works with both 2/3 python and backwards compatible.
@sposs

sposs commented Oct 3, 2016

Copy link
Copy Markdown

I would leave the _build directory of the doc out of the repository, leave the client make the doc if needed.

@sposs sposs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and necessary fixes. Otherwise, great improvement!

Comment thread geomag/latlon.py Outdated
if unit == 'degrees':
spherical_latitude = math.degrees(spherical_latitude)
spherical_longditude = math.degrees(spherical_longditude)
return (spherical_latitude, spherical_longditude, r)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parenthesis needed

@todd-dembrey todd-dembrey Oct 8, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread geomag/latlon.py Outdated
return "({} N,{} W)".format(*self._lat_lon())

def _lat_lon(self):
return(self.lat, self.lon)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parenthesis needed

@todd-dembrey todd-dembrey Oct 8, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread geomag/latlon.py Outdated
The range is limited to within +-90 and +-180 degrees
'''

if unit == 'degrees':

@sposs sposs Oct 3, 2016

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use

if units in ["deg", "degrees"]:

and

elif units in ["rad", "radians"]:

below

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like it c0f5e3c

Comment thread doc/conf.py Outdated
# General information about the project.
project = 'GeoMag'
copyright = '2015, Todd Dembrey'
author = 'Todd Dembrey'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the original author

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread doc/conf.py Outdated
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.append(r'C:\Users\todd.dembrey\git\geomag')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove explicit paths.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time_adjusted_coefficients_cache = _gen_square_array(array_size, 0.0)

def __init__(self, file):
with open(file) as world_magnetic_model_file:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No check that the file exists... Will raise an error. Is this wanted?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what else would you want it to do in this case?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually anticipate the possible errors, but here, it's true that it will raise an exception... Good enough I guess.

Comment thread geomag/world_magnetic_model.py Outdated
delta_time * self.coefficient_dot[n][m - 1])


class WorldMagneticModel:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inherit from 'object'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread geomag/world_magnetic_model.py Outdated
Example Usage:

>>> from geomag import WorldMagneticModel
>>> WorldMagneticModel().calc_mag_field(80,0).declination

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this doc string correct?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it depends on the time... The value below should not remain in the doctring as doctest doesn't like it...

@todd-dembrey todd-dembrey Oct 8, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're referring to the output. I assumed it was the method call based on the lines shown above. I haven't run doctest on it, I guess removing it is the way to clear it up.
421564e

'''
self.data = MageneticModelData(world_magnetic_model_filename)
self.k = recursion_constants(self.data.array_size)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be PEP8 compatible, all class members should be initialized in the constructor.

Comment thread geomag/world_magnetic_model.py Outdated
return_list.append(variable_dict[variable])
return return_list

if __name__ == '__main__':

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed 0ba8b1c

@todd-dembrey

Copy link
Copy Markdown
Author

@sposs I think I have included some of the changes from #7 in my enthusiasm. Thanks for the review.

@sposs

sposs commented Oct 8, 2016

Copy link
Copy Markdown

It's a big +1 for me. Great improvement!!

@rprechelt

Copy link
Copy Markdown

Any chance of this getting merged at some point? PR is a fantastic rewrite - some colleagues lost a few hours working with master before realizing that Todd's fork existed and was more up to date. Otherwise, pointing people to todd-dembrey/geomag in a README might be helpful.

@slibby

slibby commented Sep 22, 2017

Copy link
Copy Markdown

@cmweiss I would also like to start working with the rewritten branch - are you still interested in maintaining this repository or would you like to hand it off (with credit of course) so development can continue?

@singlerider

Copy link
Copy Markdown

@cmweiss @todd-dembrey Any update on this? I'm using Django 2.0.4, which requires Python 3.

@cmweiss

cmweiss commented Apr 14, 2018

Copy link
Copy Markdown
Owner

I don't think there is any Python 2 specific code. It should work with Python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants