NCAR / ldcpy

Statistical and visual tools for gathering metrics and comparing Earth System Model data files. A common use case is comparing data that has been lossily compressed with the original data.
https://ldcpy.readthedocs.io/
Apache License 2.0
19 stars 2 forks source link

times series at a single location #229

Closed allibco closed 3 years ago

allibco commented 3 years ago

From the tutorial notebook:

Time series plot of PRECT mean data for col_prect "zfpA1e-7" dataset at the location (44.76, -123.75)

ldcpy.plot(     col_prect,     "PRECT",     sets=["zfpA1e-7"],     calc="mean",     plot_type="time_series",     lat=44.76,     lon=-123.75, ) This is in the tutorial, and in my branch it is broken (probably broken in main, too) - I understand why it is broken, but I think this plot doesn't make sense.   What are we calculating the mean of?  Basically the code is trying to do the mean over time since we have only one point - but then the time dimension gets dropped and you can't plot a time series.  So I'm wondering if this is a bad example in the tutorial or we need to fix the code so calc=None is an option - then it just prints the values?  

allibco commented 3 years ago

This is the problematic call:

for d in datas: raw_metrics.append(mp.get_metrics(d))

pinarda commented 3 years ago

Note: add this plot to the test suite so we catch this issue if it comes back up

pinarda commented 3 years ago

starting on line 154 on plot.py, the ordering of the dimensions is not necessarily consistent (for example if we use subset_data() before getting the metrics), so we need a way to make sure we are finding the names of the latitude and longitude dimensions without using the ordering.

In the case above, there are three dimensions which have been reordered after using subset to ("lon", "lat", "time") and so we end up averaging over "lat" and "time", when we would expect to be averaging over "lat" and "lon"

   if len(da_data.dims) == 2:
        lat_dim = da_data.dims[0]
        lon_dim = da_data.dims[1]
    elif len(da_data.dims) == 3:
        lat_dim = da_data.dims[1]
        lon_dim = da_data.dims[2]
    elif len(da_data.dims) == 4:
        lat_dim = da_data.dims[3]
        lon_dim = da_data.dims[4]
allibco commented 3 years ago

This will be fixed in my pull request shortly....