[ncl-talk] Extracting dates when multiple conditions are met
Dennis Shea
shea at ucar.edu
Tue May 28 06:08:43 MDT 2019
; Details:
; I am extracting the dates from a netcdf file, when multiple conditions
are met. I am using NCL 6.6.2.
; Conditions:
; 1. OLR < 240
; 2. uwnd < 0
; 3. stretch_sph > 0
latS = 13.0
latN = 22.0
lonL = 120.0
lonR = 122.5
f = *addfile*("test_file_olr_wind_deform.nc","r")
olr_region = *short2flt*(f->olr(:,{latS:latN},{lonL:lonR}))
u_region = f->uwnd(:,{latS:latN},{lonL:lonR})
stretch_region = f->stretch_sph(:,{latS:latN},{lonL:lonR})
*printVarSummary*(olr_region)
*printMinMax*(olr_region,0)
print("=====")
printVarSummary(u_region)
printMinMax( u_region,0)
print("=====")
printVarSummary(stretch_region)
printMinMax(stretch_region,0)
print("=====")
olr_threshold = 240
uwnd_threshold = 0
stretch_threshold = 0
olr_thres = *dim_min_n*(olr_region,(/1,2/)) ;min at
each time step
uwnd_thres = *dim_min_n*( u_region,(/1,2/)) ;min at each
time step
stretch_thres = *dim_max_n*(stretch_region,(/1,2/)) ;max at each
time step
printVarSummary(olr_thres) ; [*]
print("=====")
printVarSummary(uwnd_thres)
print("=====")
printVarSummary(stretch_thres)
print("=====")
n_thres =* ind*((olr_thres .le. olr_threshold) .and. \
(uwnd_thres.le. uwnd_threshold) .and. \
(stretch_thres .ge. stretch_threshold))
print(n_thres)
print("=====")
TIME = u_region*&*time ; all times
YMD = *cd_calendar(*TIME,-2) ; all yyyy-mm-dd
ymd = YMD(n_thres) ; dates that satisfy criteria
print(ymd)
OLR = u_region(n_thres,:,:)
printVarSummary(OLR)
; or
u_region := u_region(n_thres,:,:)
printVarSummary(u_region)
; etc
On Sun, May 26, 2019 at 11:13 PM Lyndz <olagueralyndonmark429 at gmail.com>
wrote:
> Dear NCL-experts,
>
> *Details:*
> I am extracting the dates from a netcdf file, when multiple conditions are
> met. I am using NCL 6.6.2.
>
> The file that I am working with can be accessed from this link:
> https://www.dropbox.com/s/cycpbdgxdzsdnbh/test_file_olr_wind_deform.nc?dl=0
>
> This file contains 3 variables: OLR (short); uwnd(float);
> stretch_sph(float), with 123 timesteps.
>
> Attached is the script that I am using (date_filter.ncl).
> Also attached is the time series of OLR for verification.
>
> *Conditions:*
> 1. OLR < 240
> 2. uwnd < 0
> 3. stretch_sph > 0
>
> *Problem/What I have so far:*
> I am filtering these variables using these lines:
>
>
>
>
>
> *latS = 13.0 latN = 22.0 lonL = 120.0 lonR = 122.5*
>
> * olr_region=olr(:,{latS:latN},{lonL:lonR}) *
>
> * u_region=u(:,{latS:latN},{lonL:lonR})
> stretch_region=stretch(:,{latS:latN},{lonL:lonR})*
>
>
>
>
>
>
>
>
>
>
> * olr_threshold = 240 olr_thres = dim_min_n(olr_region,(/1,2/))
> ;min at each time step uwnd_threshold = 0 uwnd_thres =
> dim_min_n(u_region,(/1,2/)) ;min at each time step stretch_threshold
> = 0 stretch_thres = dim_max_n(stretch_region,(/1,2/)) ;max at each
> time step n_thres = ind((olr_thres .le. olr_threshold) .and.
> (uwnd_thres .le. uwnd_threshold) .and. *
> * (stretch_thres .ge. stretch_threshold))*
>
> When I print the dates, I am getting a value at *19810419*, but the time
> series shows that the OLR value at this period is above 240; hence, not
> satisfying condition 1. I would like to ask for help on how to implement
> this correctly in NCL.
>
> *Expected output:*
> Netcdf or csv file containing the dates that satisfied the 3 conditions.
>
>
> I'll appreciate any suggestions.
> --
> Lyndz
> _______________________________________________
> 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/20190528/b1f5ea38/attachment-0001.html>
More information about the ncl-talk
mailing list