Re: two files with different timesteps

From: Erik Noble <enoble_at_nyahnyahspammersnyahnyah>
Date: Tue, 05 Feb 2008 10:29:54 -0500

Ahh, I see.
I cannot install NCO operators (for ncrcat and ncks) on this particular
machine.

So I created a do loop within a do loop ( I know, its memory intensive) and
I am getting some whacky answers. I tried following your third option listed
in this manner (using wrf_user_list_times function instead of times):

a=addfile(diri1+ifile1,"r")
times = wrf_user_list_times(a)
b = addfile(FILES(ifil)+".nc","r")
 btimes = wrf_user_list_times(b)

do it = 4, ntimes-1, 8 ; TIME LOOP
  ; First get the variables we will need from WRF File

p = wrf_user_getvar(a, "pressure",it) ; pressure is our vertical coordinate
v = wrf_user_getvar(a, "va",it) ; grid point variable

; Second get the variables we will need from Reanalysis File
 do ifil = 2, numFILES-1,4 ; BIG FILES LOOP ; NEW file loop
    b = addfile(FILES(ifil)+".nc","r")
    btimes = wrf_user_list_times(b)
FNLv925 = b->VV(0,4,:,:) ; Full
FNLv700 = b->VV(0,10,:,:) ; Full
        
        if (.not.all(times.eq.btimes)) then
              print("times do not match")
              else
 
                do level = 0,nlevels-1 ; LOOP OVER LEVELS
                 pressure = pressure_levels(level)
                  v_plane = wrf_user_intrp3d( v,p,"h",pressure,0.,False)

                if ( pressure .eq. 925 ) then
         fin925_R_arr(it,level)=escorc(ndtooned(v_plane),ndtooned(FNLv925))
                        end if
                if ( pressure .eq. 700 ) then
         fin700_R_arr(it,level) =escorc(ndtooned(v_plane),ndtooned(FNLv700))
                     end if
                end do
          end if

          end do
end do

When I look at the values of fin925_R_arr or fin700_R_arr, they are all
-999. So its wrong.

IS the "if (.not.all(times.eq.btimes)) then" statement used incorrectly
here?

-Erik

On 2/4/08 9:52 PM, "Dennis Shea" <shea_at_ucar.edu> wrote:

> [1] For convenience, I suggest the netCDF operator
> "ncrcat" to combine the 2nd set of files
>
> %> ncrcat b*nc B.nc
>
> Maybe you could use ncrcat or ncks with the "d" option
> to subset B.nc to match the times on file "a"
>
> Something like [please read documentation]
>
> ncks -d,time,0,7,8 B.nc newB.nc
>
> [2] Further, assuming the times match, you could use ncdiff
> to difference the files.
>
> [3] NCL
>
> xa = fa->X
> xb = fb->X(::4,:,:) ; or whatever
>
> if (.not.all(xa&time.eq.xb&time)) then
> print("times do not match")
> exit
> end if
>
>
>
>
> Erik Noble wrote:
>> Hi. I am actually having trouble with this. Could anyone offer a suggestion
>> for my previous "loop" question below?
>> -Erik
>>
>>
>> On 2/1/08 5:14 PM, "Erik Noble" <enoble_at_giss.nasa.gov> wrote:
>>
>>
>>> Hi.
>>> Disregard my previous question. Due to an answer form an earlier post, I see
>>> that I can can get around this by creating 2 separate new arrays before
>>> entering the do loops and comparing them after.
>>> Thanks.
>>> -Erik
>>>
>>>
>>> On 2/1/08 5:04 PM, "Erik Noble" <enoble_at_giss.nasa.gov> wrote:
>>>
>>>
>>>> Hi.
>>>>
>>>> Are there any examples of reading in two different files that require
>>>> their own loops for purposes of comparing a common variable between
>>>> them?
>>>> I am trying to read in one file "a" , which is a big file that has
>>>> many timesteps (4 x daily). The other," b," is many files each with
>>>> one timestep that corresponds with the time period of "a" (except 8 x
>>>> daily).
>>>>
>> So I am trying to read in one file
>> do it = 4, ntimes-1, 8
>> And another set of files
>> do ifil = 2, numFILES-1,4
>>
>>>> Could anyone offer a suggestion?
>>>>
>>>> Thank you in advance.
>>>> Sincerely,
>>>> Erik
>>>>
>>>> Here is the first loop:
>>>>
>>>> diri1 ="/Volumes/Data_and_Models/Model-Output/Athena/"
>>>> ifile1 ="WRF-SOP3_Athena_3_1_2.nc"
>>>> a=addfile(diri1+ifile1,"r")
>>>> ; What times and how many time steps are in the data set?
>>>> times = wrf_user_list_times(a) ; get times in the file
>>>> ntimes = dimsizes(times) ; number of times in the file
>>>>
>>>> do it = 4, ntimes-1, 8 ; TIME LOOP of "a"
>>>> ; GET VARIABLE
>>>> v = wrf_user_getvar(a, "va",it) ; grid point variable
>>>>
>>>>
>>>>
>>>>
>>>> Here is the second loop:
>>>>
>>>> DATADir = "/Volumes/Data_and_Models/NAMA-SOP3/" ; path to your
>>>> data - must have trailing "/"
>>>> FILES = systemfunc ("csh -c ' ls " + DATADir + "met_em.d01.2006* '")
>>>> ; root of data file you want to plot
>>>> numFILES = dimsizes(FILES)
>>>> ;Create a loop out of how many files exist in the directory
>>>> do ifil = 2, numFILES-1,4 ; Time loop of "b"
>>>> b = addfile(FILES(ifil)+".nc","r")
>>>> ; GET VARIABLE
>>>> v700 = a->VV(0,10,1::,:)
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk_at_ucar.edu
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>
>
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Feb 05 2008 - 08:29:54 MST

This archive was generated by hypermail 2.2.0 : Tue Feb 05 2008 - 17:17:22 MST