Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Reworked Geomag #3

wants to merge 23 commits into from

Conversation

todd-dembrey
Copy link

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
Copy link

sposs commented Oct 3, 2016

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

Copy link

@sposs sposs left a 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)
Copy link

Choose a reason for hiding this comment

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

No parenthesis needed

Copy link
Author

@todd-dembrey todd-dembrey Oct 8, 2016

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)
Copy link

Choose a reason for hiding this comment

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

No parenthesis needed

Copy link
Author

@todd-dembrey todd-dembrey Oct 8, 2016

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':
Copy link

@sposs sposs Oct 3, 2016

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
Author

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'
Copy link

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
Author

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')
Copy link

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
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

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
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

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:
Copy link

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
Author

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
Copy link

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
Author

Choose a reason for hiding this comment

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

yes

Copy link

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...

Copy link
Author

@todd-dembrey todd-dembrey Oct 8, 2016

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

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__':
Copy link

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
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
Author

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

@sposs
Copy link

sposs commented Oct 8, 2016

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

@rprechelt
Copy link

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
Copy link

slibby commented Sep 22, 2017

@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

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

@cmweiss
Copy link
Owner

cmweiss commented Apr 14, 2018

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