include ERA5 atmosphere data for density splines #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A class to density_profiles was added that uses atmospheric data from ECMWF to calculate the density splines.
The ECMWF_Download file contains functions to download and read ERA5 pressure-level or model-level data files.
The pressure level data only requires the pygrib and cdsapi python packages to be installed. The download itself requires an API token in the home directory, which in turn requires an account on the cds website:
https://cds.climate.copernicus.eu/user-guide
https://cds.climate.copernicus.eu/how-to-api
The model_level data relies on the cfgrib python package and importantly the eccodes C++ package that has to be referenced. The maximum height of this atmosphere data extends up to 80 km and can be evaluated very precisely.
In the density class, both datasets are put on an Euclidian grid using the scipy.interpolate. The KDTree functionality allows the evaluation of the nearest neighbor from anywhere in the world.
To build a density spline, we evaluate a set of points along the shower trajectory of a given observer location, zenith direction, and azimuth direction. This is translated into Earth coordinates using rotations and vector addition. In principle, this class can evaluate the atmosphere data for any detector position and all shower directions around Earth and use atmospheric data for any day in the ERA5 sample lifetime.
A script that systematically evaluates all directions for a given day can be provided. I also plan to add an example notebook (which would require an example atmosphere data file).
To evaluate a specific azimuth direction, the set_theta_deg of the density spline must be used instead of the core set_theta function.