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

ERROR: KeyError: key 60096 not found #18

Closed
liamh opened this issue Jan 4, 2024 · 5 comments
Closed

ERROR: KeyError: key 60096 not found #18

liamh opened this issue Jan 4, 2024 · 5 comments
Assignees

Comments

@liamh
Copy link

liamh commented Jan 4, 2024

This appears to be coming from an attempted MSIS data download.

using SatelliteDynamics
pv = [1.0223996343275267e6, -6.548808273197852e6, 0.0, 4036.3406898714115, 630.1533154108832, 6617.161182506771]
orb  = EarthInertialState(Epoch(2023, 6, 1, 12, 0, 0, 0.0), pv, dt=1.0,
                          mass=100.0, coef_drag=1.0, area_drag=1.0, #B=0.01
                          n_grav=0, m_grav=0,
                          drag=true, srp=false,
                          moon=false, sun=false,
                          relativity=false)
t, epc, eci = sim!(orb, 86400.0)

ERROR: KeyError: key 60096 not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:484 [inlined]
  [2] ApDailyIndex
    @ ~/.julia/packages/SatelliteDynamics/JGriC/src/earth_environment/space_weather.jl:183 [inlined]
  [3] ApDailyIndex(mjd::Float64)
    @ SatelliteDynamics ~/.julia/packages/SatelliteDynamics/JGriC/src/earth_environment/space_weather.jl:186
  [4] density_nrlmsise00(epc::Epoch, x::Vector{Float64}; use_degrees::Bool)
    @ SatelliteDynamics ~/.julia/packages/SatelliteDynamics/JGriC/src/earth_environment/nrlmsise00.jl:1630
  [5] density_nrlmsise00
    @ ~/.julia/packages/SatelliteDynamics/JGriC/src/earth_environment/nrlmsise00.jl:1608 [inlined]
  [6] fderiv_earth_orbit(epc::Epoch, x::Vector{Float64}; mass::Float64, area_drag::Float64, coef_drag::Float64, area_srp::Float64, coef_srp::Float64, n_grav::Int64, m_grav::Int64, drag::Bool, srp::Bool, moon::Bool, sun::Bool, relativity::Bool)
    @ SatelliteDynamics ~/.julia/packages/SatelliteDynamics/JGriC/src/simulation/propagators.jl:60
  [7] istep(rk4::RK4, epc::Epoch, dt::Float64, x::Vector{Float64})
    @ SatelliteDynamics ~/.julia/packages/SatelliteDynamics/JGriC/src/simulation/integrators.jl:80
  [8] step!(state::EarthInertialState, dt::Float64)
    @ SatelliteDynamics ~/.julia/packages/SatelliteDynamics/JGriC/src/simulation/propagators.jl:157
  [9] sim!(state::EarthInertialState, time::Float64)
    @ SatelliteDynamics ~/.julia/packages/SatelliteDynamics/JGriC/src/simulation/propagators.jl:255
 [10] top-level scope
    @ REPL[4]:1
@duncaneddy
Copy link
Collaborator

So this issue is caused by the fact that data currently bundled with the package doesn't go through the requested date (2023-06-01, MJD 60096), the last bundled data is from 2023-04-13.

Normally you could address this by calling download_all_data() from the REPL once to update the package data files, but it looks like the source server changed their hosting location so I'll need to go in, find a new source for that data, write a new parser, and update the data if you need to use the propagation on that exact date. That is going to take me a bit to get to, though I'm happy to accept a PR as well for it.

An immediate solution would be to just choose an earlier date for the propagation, something like 2023-01-01.

@duncaneddy duncaneddy self-assigned this Jan 4, 2024
@liamh
Copy link
Author

liamh commented Jan 5, 2024

It would helpful to have a more explanatory error message that says basically what you said in your comment. However, I was actually hoping to be able to use Harris-Priester instead of MSIS, and I noticed that the H-P model is in this package, but there seems to be no way to select it in place of MSIS. I wrote a one-line fix to call H-P, but it doesn't work for me even manually loading the one calling function I patched, it always uses this repository version. (I am completely new to Julia so I don't know how to patch a package.)

So my suggestion has two parts: make this error message more meaningful to the average user (something like "date requested 2023-06-01 is beyond the end of the available MSIS data (2023-04-13), choose an earlier date"), and make it possible to switch atmosphere models.

@rolling-robot
Copy link

I also experienced this problem and worked around it by downloading data files manually from ftp://ftp.seismo.nrcan.gc.ca/spaceweather/solar_flux/daily_flux_values/fluxtable.txt and https://kp.gfz-potsdam.de/en/data, and then set manually in my code

SatelliteDynamics.GEOMAGNETIC_DATA = GeomagneticIndexData("<path_to_kpxxxx.wdc>")
SatelliteDynamics.SOLAR_FLUX_DATA = SolarFluxData("<path_to_fluxtable.txt>")

they seem to include data up to at least April 2024, but somehow they are not downloaded by download_all_data()

@duncaneddy
Copy link
Collaborator

Thank you for posting the fix and the current data sources for both files, as well as reminding me about this issue.

I plan to go in and clean up the code to:

  1. Fix download_all_data() so it properly updates data sources
  2. Download the latest data sources for all files to get the back up to date
  3. Migrate package CI GitHub Actions
  4. Setup an Action to perform a daily package data update
  5. Write a more helpful error message on out-of-bounds access to inform the user to update data.

@duncaneddy
Copy link
Collaborator

All of these issues should now be addressed with the v0.5.0 release of the package. I have completed implementing all fixes and improvements outlined above, so hopefully these issues will be more understandable in the future.

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

3 participants