mattkjames7 / PyGeopack

Wrapper for geopack-08 used for the Tsyganenko magnetic field models
GNU General Public License v3.0
11 stars 2 forks source link

Update Parameters returns error #2

Closed TeriForey closed 4 years ago

TeriForey commented 4 years ago

Hi @mattkjames7

Sorry, but I found another problem. Whenever I run gp.UpdateParameters(SkipWParameters=True) it returns the following error:

No files to update.
Reading OMNI Data
Reading Kp Indices
Creating output array
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/PyGeopack/UpdateParameters.py", line 51, in UpdateParameters
    data = _CalculateParameters(SkipWParameters)
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/PyGeopack/_CalculateParameters.py", line 387, in _CalculateParameters
    data,kp = _LoadData(years)
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/PyGeopack/_CalculateParameters.py", line 347, in _LoadData
    data.DayNo = TT.DayNo(data.Date)
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/DateTimeTools/DateTools.py", line 18, in DayNo
    if LeapYear(year) and month > 2:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

It then continues to warn me that the data file is missing, and when I tested out the TraceField functions it returned empty arrays.

mattkjames7 commented 4 years ago

That's odd, I think I might know what the problem is though, it looks like you have an old version of DateTimeTools installed. I don't appear to have put the updated version on PyPI yet either. (Sorry about that!)

Either tomorrow or Monday, I will update DateTimeTools on PyPI so that it can be installed with pip3 and I will put a minimum version requirement on it in the setup.py of this module. In the mean time, you could uninstall DateTimeTools and then clone the most recent code from https://github.com/mattkjames7/DateTimeTools - just install with python3 setup.py install --user.

TeriForey commented 4 years ago

Well I got further with the latest DateTimeTools, new error is:

No files to update.
Reading OMNI Data
Reading Kp Indices
Creating output array
Interpolating fields
Calculating dipole tilt angles
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/PyGeopack/UpdateParameters.py", line 51, in UpdateParameters
    data = _CalculateParameters(SkipWParameters)
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/PyGeopack/_CalculateParameters.py", line 391, in _CalculateParameters
    data.Tilt = GetDipoleTilt((data.Year,data.DayNo),(data.Hr,data.Mn),(data.Vx,data.Vy,data.Vz))
  File "/anaconda/envs/SMILE_dev/lib/python3.8/site-packages/PyGeopack/GetDipoleTilt.py", line 43, in GetDipoleTilt
    psi[i] = _CGetDipoleTilt(Date[i],ut[i],Vx[i],Vy[i],Vz[i])
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
mattkjames7 commented 4 years ago

Hi Teri, I think I have fixed this now, the new version of PyGeopack (0.2.5) is on PyPI now, along with the new version of DateTimeTools (0.0.6). I have changed setup.py so that it requires "DateTimeTools>=0.0.6". I have also change it such that hopefully when it fails to load libgeopackdp.so it should attempt to recompile it. Cheers, Matt.

TeriForey commented 4 years ago

It works! I reinstalled PyGeopack and on import it recompiled (successfully) the libgeopackdp.so. The updateParameters() ran successfully too! Thank you for all your help 😄

mattkjames7 commented 4 years ago

Great stuff, glad to help!