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

Plotting script radiosounding #21

Merged
merged 18 commits into from
Oct 9, 2023

Conversation

LauraKoehler
Copy link
Contributor

The folder scripts contains a script to plot the data from one sounding. It creates 5 plots: 1. the trajectory of the sonde, 2. wind speed and direct for ascent and descent, 3. temperature, dew point temperature, relative humidity, and mixing ratio for ascent and descent, 4. skewT plot for ascent, 5. skewT plot for descent.

The folder contains the python code for the plots and a Readme file.
The code has been updated to fulfill the be in accordance with PEP 8 which is checked with black and flake8.
The input file name had to be in a very specific form. Now, it can be more flexible but it should include the direction (ascent or descent). Otherwise, no SkewT plot will be created. Furthermore, this commit contains an update of the Readme.
The folder contains the python code for the plots and a Readme file.
The code has been updated to fulfill the be in accordance with PEP 8 which is checked with black and flake8.
The input file name had to be in a very specific form. Now, it can be more flexible but it should include the direction (ascent or descent). Otherwise, no SkewT plot will be created. Furthermore, this commit contains an update of the Readme.
# Define input file
filename = args["inputfile"]

data = xr.open_dataset(filename)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = xr.open_dataset(filename)
data = xr.open_dataset(filename)
data = data.pint.quantify()

This reads in the units given in the metadata of the dataset and makes the variables unit aware.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you need to use

data = data.pint.quantify(unit_registry=units)

to have the same unit registry as metpy otherwise it might get you some errors.

Copy link
Owner

@observingClouds observingClouds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LauraKoehler,
This looks already very good! The previous errors were indeed caused by scripts that you haven't touched. Now the CI runs successfully but I have a few additional suggestions to make your addition even more useful by using unit-aware functions so that the input dataset does not need to have specific units and the windspeed could for example be given in m/s instead of knots. I made some suggestions but didn't do it for all variables. Could you try to implement my suggestion and make it work for all variables? That would be very neat and I promise to accept the PR afterwards 💯

scripts/plot_radiosonde_data.py Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
scripts/plot_radiosonde_data.py Outdated Show resolved Hide resolved
# Define input file
filename = args["inputfile"]

data = xr.open_dataset(filename)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you need to use

data = data.pint.quantify(unit_registry=units)

to have the same unit registry as metpy otherwise it might get you some errors.

@observingClouds
Copy link
Owner

@LauraKoehler did my comments make sense? :)

The script now uses unit-aware function for all plots to avoid that variables have to be given in specific units in the input data.
I used an older metpy version which produces a white space left of the skewT diagram due to the rotation of the T axis. This problem is solved with a newer metpy version but I had to make a few changes in the way the numbers like CAPE and CIN are rounded for the inset to use the round function only on a float which didn't matter before.
@LauraKoehler
Copy link
Contributor Author

LauraKoehler commented Oct 9, 2023

@observingClouds, the comments make sense indeed and I updated the script accordingly such that the units are taken into account now and variables don't have to have specific units anymore. In this context, I had to do a few additional changes since I use another version of metpy now. I hope, it's more version independent now. ;-)

@observingClouds
Copy link
Owner

Hi @LauraKoehler,
This looks and works great now! Thanks for doing this extra effort. I made some minor changes and also added a test for your plotting function. The only remaining issue I have is that the trajectory figure has to axes. Do you think you could fix that?
Screenshot 2023-10-09 at 13 12 16

see artifacts at https://github.com/observingClouds/pysonde/actions/runs/6461156965

@observingClouds
Copy link
Owner

Never mind! I found the issue. All looks great!
track_2020-01-26T2244_ascent

@observingClouds observingClouds merged commit 158b79c into observingClouds:master Oct 9, 2023
3 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants