space-physics / igrf

International Geomagnetic Reference Field IGRF13 in Python and Matlab
https://www.ngdc.noaa.gov/IAGA/vmod/
MIT License
66 stars 28 forks source link

Use igrf C code instead of Fortran. #2

Open Jammyjamjamman opened 6 years ago

Jammyjamjamman commented 6 years ago

Firstly, thanks for this awesome repository! It has been really useful to me!

I think it would be better if the repository used the C IGRF code because:

  1. C is better than Fortran (well... ok this isn't really true anymore, but it is true for old Fortran like seen in the IGRF code).

  2. Most people have a C/C++ compiler already for installing python packages, but not a Fortran compiler. I was using anaconda python on ubuntu and I had to install fortran to install this. (You can also install fortran from the anaconda repo).

Of course, this is not an essential project. I just think it might be a nice improvement. If it's too difficult, then I wouldn't worry about it.

scivision commented 6 years ago

Hi @Jammyjamjamman I think that would be fine to have the C version of IGRF as a reference. Feel free to pull request it :+1: It is not too difficult.

Jammyjamjamman commented 5 years ago

Hi, @scivision , sorry for taking a year to respond... Would you still be interested in me implementing this?

Here is what my plan would be to implement it:

scivision commented 5 years ago

I just checked and put the C code in this repo for future reference. I didn't have any issues compiling with Visual Studio or any other modern C compiler I tried. The C source code for the geomag_windows and geomag_linux is exactly the same. I would need to make an interface for this C code.

Jammyjamjamman commented 5 years ago

I just checked and put the C code in this repo for future reference. I didn't have any issues compiling with Visual Studio or any other modern C compiler I tried. The C source code for the geomag_windows and geomag_linux is exactly the same. I would need to make an interface for this C code.

SWIG interfaces are the easiest way I know of doing this. Could also be done as a pure python module (hard) or using Cython.