Looping Through Levels #2752
-
Hi: I am running PCP-Combine on a 30 year dataset. The data is stored as 1 file per year, and each file has 12 timesteps (one per month). What I need to do is calculate a mean and standard deviation for each month across the entire dataset. I tested my setup using the following: VALID_BEG = 2020010100 OBS_PCP_COMBINE_RUN = True OBS_PCP_COMBINE_METHOD = DERIVE OBS_PCP_COMBINE_INPUT_ACCUMS = 1Y OBS_PCP_COMBINE_INPUT_NAMES = SWVL1 OBS_PCP_COMBINE_DERIVE_LOOKBACK = 946080000S Note that using OBS_PCP_COMBINE_DERIVE_LOOKBACK = 30Y doesn't work (for reasons I don't want to get into here). The above settings work fine for January, but I need to do all months, which means looping through the levels in a file. I'm struggling to figure out a good way to do this. I first tried a custom loop list using the settings below: CUSTOM_LOOP_LIST = 0, 1, etc... However, this doesn't work. I get an error regarding string substitution: I know that time templates can be placed inside the level as OBS_PCP_COMBINE_INPUT_LEVELS ="({valid?fmt=%Y%m%d_%H%M%S},,)". However, each file contains a different year of data and therefore a different date. So this does not work either. At this point, the only way I could think to do this would be to write a python embedding script that takes the current month of data as input (rather than reading the data directly). From there, I could parse the current month inside the python embedding script. If I switch the valid increment (VALID_INCREMENT = 1m), this should allow looping over all months of data. But, before I went through the process of writing a python embedding script, I thought I would ask.... Do we have any other ways of looping through levels that I may be unaware of? Tina |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I was going to suggest that you do something like this:
but I don't think that you would be able to shift the first month to be 0. You could try it but I'm guessing it will not work. It could be nice to support arithmetic operations here, e.g. The custom loop list approach should work, but it appears that it does not. I think I see in the code where the @JohnHalleyGotway, can you think of any other clever ways to get the desired NetCDF data that I'm not thinking of? |
Beta Was this translation helpful? Give feedback.
-
@CPKalb and I discussed this via Slack and discovered that a bug in PCPCombine derive method was preventing the use of the full valid time in the field info. I created issue #2762 and PR #2764 to fix this for 6.0.0. |
Beta Was this translation helpful? Give feedback.
@CPKalb and I discussed this via Slack and discovered that a bug in PCPCombine derive method was preventing the use of the full valid time in the field info. I created issue #2762 and PR #2764 to fix this for 6.0.0.