-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reworked Geomag #3
base: master
Are you sure you want to change the base?
Conversation
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.
I would leave the _build directory of the doc out of the repository, leave the client make the doc if needed. |
There was a problem hiding this comment.
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!
if unit == 'degrees': | ||
spherical_latitude = math.degrees(spherical_latitude) | ||
spherical_longditude = math.degrees(spherical_longditude) | ||
return (spherical_latitude, spherical_longditude, r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parenthesis needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "({} N,{} W)".format(*self._lat_lon()) | ||
|
||
def _lat_lon(self): | ||
return(self.lat, self.lon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parenthesis needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range is limited to within +-90 and +-180 degrees | ||
''' | ||
|
||
if unit == 'degrees': |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like it c0f5e3c
# General information about the project. | ||
project = 'GeoMag' | ||
copyright = '2015, Todd Dembrey' | ||
author = 'Todd Dembrey' |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove explicit paths.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
delta_time * self.coefficient_dot[n][m - 1]) | ||
|
||
|
||
class WorldMagneticModel: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inherit from 'object'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example Usage: | ||
|
||
>>> from geomag import WorldMagneticModel | ||
>>> WorldMagneticModel().calc_mag_field(80,0).declination |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
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.
return_list.append(variable_dict[variable]) | ||
return return_list | ||
|
||
if __name__ == '__main__': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed 0ba8b1c
It's a big +1 for me. Great improvement!! |
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. |
@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? |
@cmweiss @todd-dembrey Any update on this? I'm using Django 2.0.4, which requires Python 3. |
I don't think there is any Python 2 specific code. It should work with Python 3. |
Major rework, changes include:
Works with both 2/3 python and backwards compatible.
Happy to discuss further changes if required?