[ncl-talk] Removing some data from NetCDF file for a specific date
Dennis Shea
shea at ucar.edu
Fri Jan 17 10:34:04 MST 2020
As noted by DaveA, the question is ambiguous.
The following will set the times times by the user. to _FillValue
Sine _FillValue are not used in any computation, this is similar to
'removing' the times from the variable.
ymd_exclude = (/19830131, 19850202, 19890610/) ; times to remove
diri = "./" ; input directory
fili = "model.nc"
f = *addfile*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml>(diri+fili,
"r")
x = f->X
printVarSummary(x)
ymd = *cd_calendar*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml>(x&time,
-2) ; yyyymmdd ... all ymd in file
nt_exclude = *get1Dindex_Exclude*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/get1Dindex_Exclude.shtml>(ymd,
ymd_exclude)
x(nt_exclude,...) = x at _FillValue ; set all remove time
to _FillValue
;
size of 'x' unchanged
======
Alternatively, actually remove the 'ymd_exclude' times from the variable.
The size of the array wil change.
nt_collapse = *get1Dindex_Collapse*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/get1Dindex_Collapse.shtml>(ymd,
ymd_exclude)
x *:=* x(nt_collapse,...) ; note use of
'reassignment' operator [ *:=* ]
printVarSummary(x) ; note change of size
=======
Other useful index utility functions
*get1Dindex* <http://www.ncl.ucar.edu/Document/Functions/Contributed/get1Dindex.shtml>,
*ind* <http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml>
On Fri, Jan 17, 2020 at 4:02 AM Setareh Rahimi via ncl-talk <
ncl-talk at ucar.edu> wrote:
> Dear Dave,
> I have only my NCL script to plot some variables from model results. As I
> mentioned before in those model results there are some specific dates that
> I need to remove. So I am seeking a way t do so, and I did not write any
> application program in NCL to remove them.
> Best wishes,
>
> On Fri, Jan 17, 2020 at 2:31 AM Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Please keep replies on the mailing list. I assumed that you were writing
>> your own application program in NCL. Is this correct, or do you just want
>> to make reduced files?
>>
>>
>> On Thu, Jan 16, 2020 at 5:38 AM Setareh Rahimi <setareh.rahimi at gmail.com>
>> wrote:
>>
>>> Dear Dave,
>>> Many thanks for your email, and apologize for the slow reply. Well, I
>>> think method 2 should be fine. However, which application program do you
>>> suggest?
>>> Best wishes,
>>>
>>> On Tue, Jan 7, 2020 at 10:58 PM Dave Allured - NOAA Affiliate <
>>> dave.allured at noaa.gov> wrote:
>>>
>>>> I can think of at least three ways to do this.
>>>>
>>>> 1. Write a program to copy grids from a model file into a new file,
>>>> but skip selected dates.
>>>> 2. In your application program, remove the selected dates from a copy
>>>> of the model data in program memory.
>>>> 3. In your application program, read in only the dates wanted, and
>>>> skip the dates to be removed.
>>>>
>>>> I recommend methods 2 or 3 because they are fast and efficient, and
>>>> need less programming than the first method. 2 and 3 require the ability
>>>> to make changes to your application program. Which method fits your needs?
>>>>
>>>>
>>>> On Tue, Jan 7, 2020 at 1:23 AM Setareh Rahimi via ncl-talk <
>>>> ncl-talk at ucar.edu> wrote:
>>>>
>>>>>
>>>>> Dear all,
>>>>>
>>>>> I have some model outputs in the NetCDF format. I need to remove the
>>>>> results from the files for some specific dates (like 2008/02/04). So would
>>>>> you please kindly advise me how can I do so?
>>>>> Many thanks in advance,
>>>>> Best wishes,
>>>>> --
>>>>> S.Rahimi
>>>>>
>>>>
>
> --
> S.Rahimi
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200117/501a5ace/attachment.html>
More information about the ncl-talk
mailing list