CEMPD / VERDI

This is the repo for the VERDI project, written in java.
GNU General Public License v3.0
16 stars 13 forks source link

script method to create tile plot mean of variable and mean of a subset of time for a variable #301

Open lizadams opened 2 years ago

lizadams commented 2 years ago

Describe the bug User would like to plot the mean of a subset of time of a variable using the command line.

There are three related issues.

  1. the tile plot of the mean of the Ozone variable from the command line of all of the timesteps available in the file does not match the mean of Ozone variable generated using the STATS pull down option then select mean.

  2. It is possible to subset the time using the GUI and then use the pull down STATS menu to select mean of the variable, but it is not possible to do this using the command line.

  3. the documentation states that -tinit should start at 0, which fails

To Reproduce Steps to reproduce the behavior:

  1. Comparison between tile plot generated by script taking mean of variable and tile plot generated interactively using STATS Menu option: Mean

Command line script to generate mean of O3 variable using syntax:

./verdi.sh -f $cwd/data/model/CCTM46_P16.baseO2a.36k.O3MAX -s "mean(O3[1])" -g tile -saveImage "png" $cwd/data/plots/CCTM46_P16.baseO2a.36k.O3.mean.png -quit

Plot generated by script: CCTM46_P16 baseO2a 36k O3 mean

Plot generated through gui after starting up verdi and creating a tile plot, then selecting the STATS pull-down menu option and selecting mean

./verdi.sh -f $cwd/data/model/CCTM46_P16.baseO2a.36k.O3MAX -s "O3[1]" -g tile

Output from GUI STATS > MEAN

CCTM46_P16 baseO2a 36k O3 STATS-MEAN
  1. command line option to create tile plot of the mean of a subset of the timesteps in the datasets.

./verdi.sh -f $cwd/data/model/CCTM46_P16.baseO2a.36k.O3MAX -tinit 1 -tfinal 10 -s"mean(O3[1])"

Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option --illegal-access=permit; support was removed in 17.0
2022.06.13 16:41:32.954 [Thread-2] ERROR anl.verdi.plot.gui.FastTilePlot - Error rendering FastTilePlot
java.lang.ArrayIndexOutOfBoundsException: null
    at ucar.ma2.Index4D.set0(Index4D.java:123) ~[netcdfAll-4.5.5-SNAPSHOT.jar:?]
    at ucar.ma2.Index4D.set(Index4D.java:160) ~[netcdfAll-4.5.5-SNAPSHOT.jar:?]
    at anl.verdi.data.DataFrameIndex.setTime(DataFrameIndex.java:79) ~[core.jar:?]
    at anl.verdi.data.DataFrameIndex.set(DataFrameIndex.java:149) ~[core.jar:?]
    at anl.verdi.plot.gui.FastTilePlot.copySubsetLayerData(FastTilePlot.java:1926) ~[core.jar:?]
    at anl.verdi.plot.gui.FastTilePlot.access$16(FastTilePlot.java:1888) ~[core.jar:?]
    at anl.verdi.plot.gui.FastTilePlot$5.run(FastTilePlot.java:574) [core.jar:?]
    at java.lang.Thread.run(Thread.java:833) [?:?]

Expected behavior Expect to be able to subset the time range from 1 hour to 10 hours out of the 24 hours of data in the file, and then take the mean of the Ozone variable.

Screenshots

verdi_time_subset_error

Another syntax option that would be helpful to support to subset the time range is to bracket the time range in the formula as follows:

./verdi.sh -f $cwd/data/model/CCTM46_P16.baseO2a.36k.O3MAX -s"mean(O3[1]:1-10)" -g tile

The above command does not give an error, but it does generate a plot of the mean of Ozone for all timesteps, eequivalent to that produced using the command line for the mean.

./verdi.sh -f $cwd/data/model/CCTM46_P16.baseO2a.36k.O3MAX -s"mean(O3[1])" -g tile

  1. ./verdi.sh -f $cwd/data/model/CCTM46_P16.baseO2a.36k.O3MAX -tinit 0 -tfinal 10 -s "mean(O3[1])" -g tile

Output:

OpenJDK 64-Bit Server VM warning: Option --illegal-access is deprecated and will be removed in a future release.
2022.06.13 17:14:13.503 [main] ERROR anl.verdi.plot.gui.FastTilePlot - Exception setting time step. Time step = -1. Is this 1-based?
java.lang.NullPointerException: Cannot invoke "java.util.GregorianCalendar.getTime()" because "date" is null
    at anl.verdi.util.Utilities.formatShortDate(Utilities.java:47) ~[core.jar:?]
    at anl.verdi.plot.gui.TimeLayerPanel$SpinnerListener.stateChanged(TimeLayerPanel.java:42) ~[core.jar:?]

Expected behavior Expect to be able to follow the user manual and specify the -tinit to start at zero.

Recommended Fix for sub-issue #3 (this has been fixed in the documentation by pull request https://github.com/CEMPD/VERDI/pull/302/files The user manual needs to be corrected to state that the timestep should start at 1 rather than zero. https://github.com/CEMPD/VERDI/blob/master/doc/User_Manual/VERDI_ch18.md

Desktop (please complete the following information):

Additional context Also obtained the same behavior with 2.1.3