[ncl-talk] extracting Wrf Varibales and Times

afwande juliet afwandej965 at gmail.com
Tue Dec 8 01:35:28 MST 2015


ok Mary
thanks. Does this code assume the data is daily since my data (wrfoutput)
is 3hourly. If that's the case must I convert data to monthly or daily?
I would appreciate

On Mon, Dec 7, 2015 at 8:17 AM, Mary Haley <haley at ucar.edu> wrote:

> WRF output files store their "times" array as strings, so you probably
> need to read these off the files and parse them.  You should be able to do
> this with str_split_csv.
>
> For example, let's say you open the files and read the "Times" variable
> with:
>
> [UNTESTED]:
>
>   files = systemfunc("ls wrfout_d01*")
>   files = files + ".nc"
>
>   f     = addfiles(files,"r")
>   times = wrf_user_list_times(f)   ; Read "Times" off the file
>
> You can then parse the "times" array using "str_split_csv" to split the
> fields on the "-" and "_" characters, which is what separates the years,
> months, and days:
>
> ;--Parse the WRF times string to get the months as integers.
>   str1       = str_split_csv(times,"-",0)     ; first split on "-"
>   str2       = str_split_csv(str1(:,2),"_",0) ; now split on "_""
>
>   wrf_months = toint(str1(:,1))   ; should be integers from 1 to 12
>
> Now that you have "wrf_months", you can use the "ind" function to grab the
> months you want:
>
> ;---Get the index locations for MAM and OND
>   mam_ind = ind(wrf_months.ge. 3.and.wrf_months.le. 5)
>   ond_ind = ind(wrf_months.ge.10.and.wrf_months.le.12)
>
> ;
> ; You may not have any need for the wrf_times_mam and
> ; wrf_times_ond arrays, but I'm including them here to
> ; see what they look like.
> ;
>   wrf_times_mam = times(mam_ind)
>   wrf_times_ond = times(ond_ind)
>
>   print("MAM: " + wrf_times_mam)
>   print("OND: " + wrf_times_ond)
>
> These index values can  be used to index any WRF variable that you read
> with "wrf_user_getvar", or straight off the file:
>
> ;---Read all sea level pressures off the files
>   slp = wrf_user_getvar(f,"slp",-1)   ; sea level pressure
>
> ;---Grab only MAM and OND seasons of slp
>   slp_mam = slp(mam_ind,:,:)     ; this assumes "slp" is 3D
>   slp_ond = slp(ond_ind,:,:)
>
> Let me know if this is not what you needed.
>
> --Mary
>
>
>
> On Sun, Dec 6, 2015 at 12:53 AM, afwande juliet <afwandej965 at gmail.com>
> wrote:
>
>> Dear NCL users
>> I have many files from wrf output like this etc..
>>
>> wrfout_d01_1982-02-01_00:00:00
>> wrfout_d01_1982-06-06_00:00:00
>> wrfout_d01_1982-10-09_00:00:00
>> wrfout_d01_1997-02-01_00:00:00
>> wrfout_d01_1997-03-03_03:00:00
>> wrfout_d01_1997-06-04_03:00:00
>> wrfout_d01_1997-07-04_03:00:00
>> wrfout_d01_1997-07-29_03:00:00
>> wrfout_d01_1997-09-29_15:00:00
>>
>> I want to extract only 6variables for MAM and OND seasons for all the
>> files so that whatever files I will finally  have will contain only
>> 6variables for times march-May and October -Dec
>>
>> Is there a way I can do this in NCL, I am trying to check the NCL
>> documentations script at
>> http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/BASIC_SFC/wrf_Surface_multi_input_files.htm
>> but can get way out
>>
>> _______________________________________________
>> 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/20151208/2467f691/attachment.html 


More information about the ncl-talk mailing list