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

Module for interactive time series postprocessing in Python shell #22

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

guilhermeltm
Copy link
Collaborator

Module for interactively plotting time series from MPAS raw output files
at particular points. Usage example from Python shell:

########################################################################
import matplotlib.pyplot as plt; from interactive_ts import ts, plot_ts

dir='/path/to/data';
stream='history'; t0='2021-01-01 00:00:00'; tf='2021-01-02 18:00:00';
dt='10800'; var='swdnb'; lat='-52'; lon='-2'; vertlevel='0'

t1,y1,label1=ts(dir=dir,stream=stream,t0=t0,tf=tf,dt=dt,var=var,lat=lat,
lon=lon,vertlevel=vertlevel)

var='swupb'

t2,y2,label2=ts(dir=dir,stream=stream,t0=t0,tf=tf,dt=dt,var=var,lat=lat,
lon=lon,vertlevel=vertlevel)

y3=y1+y2
label3='total'

plot_ts(t1,y1,label1,ofile='y1.png')
plot_ts(t2,y2,label2,ofile='y1_y2.png')
plot_ts(t2,y3,label3,ofile='y1_y2_y3.png')
########################################################################

@guilhermeltm guilhermeltm marked this pull request as ready for review April 3, 2024 18:57
@guilhermeltm guilhermeltm requested a review from favba April 3, 2024 18:58
@guilhermeltm
Copy link
Collaborator Author

@favba as stated in the description, this should help interactively plotting time series from MPAS raw output data in a Python shell. Could you please just test the usage example above, if you have some "history" data?

Thanks!

PS: I opened this branch from the previous gtm/time-series-at-grid-cell, but deleted the scripts that were created only there to make clearer which scripts are new here (compared to master).

@favba
Copy link
Collaborator

favba commented Jun 12, 2024

Hi @guilhermeltm , I'm finally downloading the history files to test this PR (and the other one).
I'm downloading several files named diag.2021-01-01_00.00.00.nc, with changing time stamps (hourly).

In this case, should the stream variable in your example be set to 'diag'? Is that it?

@favba
Copy link
Collaborator

favba commented Jun 12, 2024

I just tested this but got an error at
t1,y1,label1=ts(dir=dir,stream=stream,t0=t0,tf=tf,dt=dt,var=var,lat=lat,lon=lon,vertlevel=vertlevel)

In [7]: t1,y1,label1=ts(dir=dir,stream=stream,t0=t0,tf=tf,dt=dt,var=var,lat=lat,lon=lon,vertlevel=vertlevel)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/.miniforge3/envs/mpas-tools/lib/python3.12/site-packages/xarray/core/dataset.py in ?(self, names)
   1408                 variables[name] = self._variables[name]
   1409             except KeyError:
-> 1410                 ref_name, var_name, var = _get_virtual_variable(
   1411                     self._variables, name, self.dims

KeyError: 'latVertex'

I just checked the NC files; indeed, there is no latVertex field.
I'm using the files you sent the link to me (months ago). Could they have changed since?

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.

2 participants