I have a multi-year nc file with daily data. I want to select all of the data (at one lat-lon point) with dates falling within +-15 days of a specified date. For instance, for Jan 1, I'd want the data for all dates from Dec 17 through Jan 16 for all years. Is there a relatively simple way to do that?
Here's an addendum - perhaps a simpler problem. I saw an older post (~2009) where someone was trying to extract sets of days (all 122 days in JJAS) for files with multiple years of data. A solution was expected a year from then -- was this solved? If so, that would be another approach I could use.
Please try these:
import cdms2,cdtime
f=cdms2.open("your_file_nm")
V=f["your_variable"]
Lat = 0.
Lon = 0.
centerTime=cdtime.comptime(2013,7,11)
Delta = 15
units=cdtime.Day
t1=centerTime.add(-Delta,units)
t2=centerTime.add(Delta,units)
Data = V(time=(t1,t2,'ccb'),latitude=(Lat,Lat,'cob'),longitude=(Lon,Lon,'cob'))
print Data.shape
From: "Ed M." edmhydro@users.sf.net<mailto:edmhydro@users.sf.net>
Reply-To: "[cdat:support-requests]" 12@support-requests.cdat.p.re.sf.net<mailto:12@support-requests.cdat.p.re.sf.net>
Date: Friday, July 12, 2013 1:58 PM
To: "[cdat:support-requests]" 12@support-requests.cdat.p.re.sf.net<mailto:12@support-requests.cdat.p.re.sf.net>
Subject: [cdat:support-requests] #12 Question on selecting multi-year date windows
Here's an addendum - perhaps a simpler problem. I saw an older post (~2009) where someone was trying to extract sets of days (all 122 days in JJAS) for files with multiple years of data. A solution was expected a year from then -- was this solved? If so, that would be another approach I could use.
[support-requests:#12]http://sourceforge.net/p/cdat/support-requests/12/ Question on selecting multi-year date windows
Status: open
Created: Mon Jul 08, 2013 11:49 PM UTC by Ed M.
Last Updated: Mon Jul 08, 2013 11:49 PM UTC
Owner: nobody
I have a multi-year nc file with daily data. I want to select all of the data (at one lat-lon point) with dates falling within +-15 days of a specified date. For instance, for Jan 1, I'd want the data for all dates from Dec 17 through Jan 16 for all years. Is there a relatively simple way to do that?
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/cdat/support-requests/12/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Related
Support Requests: #12
Thanks, Charles. That is very helpful, and will work in my case if I scroll through each year and choose those segments and concatenate the data. But with a single file containing 150 years of daily data this seems inefficient. Is there a way to select all of the days in a window (for example, select all of the January days in the file, so 150 x 31 days)? This would be like the cdo function 'selmon'.