timduly4 / pyglow

Upper atmosphere climatological models in Python
MIT License
104 stars 57 forks source link

User indices input different results #77

Closed RobertoMantas closed 2 years ago

RobertoMantas commented 5 years ago

Dear @timduly4 I have been doing some tests with the optionuser_ind and saw some weird output going on. After that, I tested the file test_user_indices.py in which it runs the same value for indices as default and defined by the user. But the output is different.

For example using the following code:

 #! /usr/bin/env python
from datetime import datetime
import pyglow
from pyglow import Point
lat = 30.
lon = -10.
alt = 250.
dn = datetime(2000, 1, 1)

print("Testing user defined indices in IRI:")
print("------- ---- ------- ------- -- ----")
# Using default F10.7:
pt = Point(dn, lat, lon, alt)
pt.run_iri()
print("Using default F10.7:")
print("f10.7 = {:3.2f}".format(pt.f107))
print("f10.7a = {:3.2f}".format(pt.f107a))
print("ne = {:3.2f}".format(pt.ne))
print("")

# Using user-defined F10.7:
pt = Point(dn, lat, lon, alt, user_ind=True)
pt.f107 = 125.6 # We need to define our F10.7, now
pt.f107a = 160.55 # We need to define our F10.7a, now
pt.run_iri()
print("Using user defined F10.7:")
print("f10.7 = {:3.2f}".format(pt.f107))
print("f10.7a = {:3.2f}".format(pt.f107a))
print("ne = {:3.2f}".format(pt.ne))
print("")

The given output is:

Testing user defined indices in IRI:


Using default F10.7: f10.7 = 125.60 f10.7a = 160.55 ne = 361218.21

Using user defined F10.7: f10.7 = 125.60 f10.7a = 160.55 ne = 360263.09

We can see that having the same indices the ne variable it has a different value, but at least is quite similar so let's say there is no problem with that. The problem comes when I run the second part of the code with the user_ind only without running first the default code. In this case, the output is very different from the previous values.

Running only this part of the code:

#! /usr/bin/env python
from datetime import datetime
import pyglow
from pyglow import Point
lat = 30.
lon = -10.
alt = 250.
dn = datetime(2000, 1, 1)
# Using user-defined F10.7:
pt = Point(dn, lat, lon, alt, user_ind=True)
pt.f107 = 125.6 # We need to define our F10.7, now
pt.f107a = 160.55 # We need to define our F10.7a, now
pt.run_iri()
print("Using user defined F10.7:")
print("f10.7 = {:3.2f}".format(pt.f107))
print("f10.7a = {:3.2f}".format(pt.f107a))
print("ne = {:3.2f}".format(pt.ne))
print("")

With this code alone without running the default before the output is the following:

Testing user defined indices in IRI:


Using user defined F10.7: f10.7 = 125.60 f10.7a = 160.55 ne = 328667.37

The variable ne is 328667.37 instead of 361218.21 from default or 360263.09 from the user_ind from before. What do you think is happening here? Any help would be appreciated. I saw there is an issue talking about this variable in #34. But thought this was a new issue that came up.
Thank you very much @timduly4 again for your support.

timduly4 commented 5 years ago

@RobertoMantas This is indeed strange-- give me a few days to investigate.

timduly4 commented 5 years ago

@RobertoMantas just so we're on the same page, we're seeing an issue with specifying the user indices after we have already executed IRI without the user indices-- correct?

That is, in file1.py:

from datetime import datetime
from pyglow import Point

lat = 30.
lon = -10.
alt = 250.
dn = datetime(2000, 1, 1)

print("------------------------------------")
print("           file1.py                 ")
print("------------------------------------")

pt = Point(dn, lat, lon, alt, user_ind=True)
pt.f107 = 125.6
pt.f107a = 160.55
pt.run_iri()
print("Using user defined F10.7:")
print("f10.7 = {:3.2f}".format(pt.f107))
print("f10.7a = {:3.2f}".format(pt.f107a))
print("ne = {:3.2f}".format(pt.ne))
print("")

And in file2.py:

from datetime import datetime
from pyglow import Point

lat = 30.
lon = -10.
alt = 250.
dn = datetime(2000, 1, 1)

print("------------------------------------")
print("           file2.py                 ")
print("------------------------------------")

pt = Point(dn, lat, lon, alt)
pt.run_iri()
print("Using default F10.7:")
print("f10.7 = {:3.2f}".format(pt.f107))
print("f10.7a = {:3.2f}".format(pt.f107a))
print("ne = {:3.2f}".format(pt.ne))
print("")

pt = Point(dn, lat, lon, alt, user_ind=True)
pt.f107 = 125.6
pt.f107a = 160.55
pt.run_iri()
print("Using user defined F10.7:")
print("f10.7 = {:3.2f}".format(pt.f107))
print("f10.7a = {:3.2f}".format(pt.f107a))
print("ne = {:3.2f}".format(pt.ne))
print("")

We expect similar results, but the two files yield different results:

~/Desktop/pyglow_issue $ python file1.py 
------------------------------------
           file1.py                 
------------------------------------
Using user defined F10.7:
f10.7 = 125.60
f10.7a = 160.55
ne = 328667.37

~/Desktop/pyglow_issue $ python file2.py 
------------------------------------
           file2.py                 
------------------------------------
Using default F10.7:
f10.7 = 125.60
f10.7a = 160.55
ne = 361218.21

Using user defined F10.7:
f10.7 = 125.60
f10.7a = 160.55
ne = 360263.09

This looks to be some odd initialization with IRI. Perhaps @butala has some insight? (Have we run into a similar issue previously?). It'd be interesting to see if we can reproduce this problem in Fortran, but I'm not sure if I can garner the volunteers...

RobertoMantas commented 5 years ago

Yes, @timduly4 that is exactly the problem. Let's see if @butala could help. If there is anything I could do to help let me know. I have seen the Fortran code in the irimodel.org, but haven't tried to run it. Thank you!

RobertoMantas commented 5 years ago

Dear @timduly4 any news on this?? thank you in advance!

timduly4 commented 5 years ago

@RobertoMantas I haven't had time to deeply investigate this issue, yet. I'll keep you updated once I am able.

RobertoMantas commented 5 years ago

Hello @timduly4 :) do you know if anyone else is facing the same problem? Did you have time to have a look into it? Thank you very much for your time.

timduly4 commented 5 years ago

@RobertoMantas This looks like some sort of memory issue within Fortran. Unfortunately I'm short on time these days, so I might have to stash this issue in the icebox for a bit.

Can you reproduce this issue in Fortran? Let me know, and we can work from there.

bharding512 commented 2 years ago

Closing (stale issue) but feel free to reopen