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

How can i reslove this valueerror with MSIS model #154

Closed
mkmohamed opened this issue Nov 12, 2023 · 3 comments
Closed

How can i reslove this valueerror with MSIS model #154

mkmohamed opened this issue Nov 12, 2023 · 3 comments

Comments

@mkmohamed
Copy link

Hi Everybody,
Please I would like to run msis model by executing the code below:

import numpy as np
from datetime import datetime, timedelta
import pyglow

lat = 31.37 #Morocco
lon = -7.5
alt = 250.
alts = np.arange(200,800,1)

dn_lt = datetime(2023, 11, 10, 0, 0)
pt.run_msis(version=2000)

I got this value error. How can i resolve this please?

ValueError Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 pt.run_msis(version=2000)

File ~/.local/lib/python3.9/site-packages/pyglow/pyglow.py:273, in Point.run_msis(self, version)
266 """
267 Run the MSIS climatological model
268
269 :param version: Version of MSIS to run
270 """
272 # Run MSIS:
--> 273 self.msis.run(
274 self.location_time,
275 self.f107a,
276 self.f107p,
277 self.apmsis,
278 version=version,
279 )
281 # Assign output:
282 self.Tn_msis = self.msis.Tn

File ~/.local/lib/python3.9/site-packages/pyglow/msis.py:39, in MSIS.run(self, location_time, f107a, f107p, apmsis, version)
33 raise ValueError(
34 "Invalid version of '{}' for MSIS.\n".format(version) +
35 "2000 (default) is valid."
36 )
38 # Call MSIS:
---> 39 [d, t] = msis(
40 location_time.doy,
41 location_time.utc_sec,
42 location_time.alt,
43 location_time.lat,
44 np.mod(location_time.lon, 360),
45 location_time.slt_hour,
46 f107a,
47 f107p,
48 apmsis,
49 48,
50 )
52 # Neutral temperature:
53 self.Tn = t[1] # neutral temperature from MSIS (K)

ValueError: msis00py.msis00py.gtd7: failed to create array from the 9th argument ap -- 0-th dimension must be fixed to 7 but got 8

@bharding512
Copy link
Collaborator

How are you initializing "pt"? You could try something like:

pt = pyglow.Point(dn_lt, lat, lon, alt, user_ind=True)
pt.f107 = 70.
pt.f107a = 70.
pt.f107p = 70.
pt.apmsis= [0, 0, 0, 0, 0, 0, 0]
pt.run_msis()

(I haven't tested this code, but hopefully you get the idea)

Let me know if you're still having problems and I'll look into it further.

@mkmohamed
Copy link
Author

Hi @bharding512 Thank you again for your response.

1- First of all, Your code worked for me, but I didn't understand why we have to initialize "pt"and define ourselves indices to be able to have msis running.
2- Isn't pyglow able to deliver/use the indices values automatically.
3- And if this is the only way to run msis with pyglow, should we use the correct values of this indices in the initialization phase? just to make sure that pyglow doesn't correct/adjust this values before running Msis.

Thank you

@bharding512
Copy link
Collaborator

1- First of all, Your code worked for me, but I didn't understand why we have to initialize "pt"and define ourselves indices to be able to have msis running.

The philosophy with pyglow is that the top-level class is a "Point" and all the functions are called on that point. It's not meant to be a standalone MSIS wrapper, for example.

2- Isn't pyglow able to deliver/use the indices values automatically.

In theory, it's supposed to do that. But the sources of these indices have changed over the years, and pyglow is way behind on maintenance. See, for example, open issues #105 and #151. Pull requests are very welcome.

3- And if this is the only way to run msis with pyglow, should we use the correct values of this indices in the initialization phase? just to make sure that pyglow doesn't correct/adjust this values before running Msis.

If you set user_ind=True, it won't overwrite the F10.7 or Ap before the MSIS call.

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

No branches or pull requests

2 participants