Re: Convert data for another resolution

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu, 08 Mar 2007 15:03:02 -0700

Hi Sara,

One thing I just noticed was that your latitudes are going from
north->south.. linint2 expects your latitudes to be monotonically
increasing. Thus, you should flip the latitudes of your input data:

begin
   in = addfile("prate_media2.nc", "w")
   data = in->prate
   data = data(:,::-1,:)
   new_lon = fspan(1.25, 358.75, 144)
   new_lat = fspan(-88.75, 88.75, 72) ; go from S->N
   new_data = linint2_Wrap(data&lon,data&lat,data,True,new_lon,new_lat,0)

   new_data!0 ="lat"
   new_data!1 = "lon"
   new_data&lat = new_lat
   new_data&lon = new_lon
   new_data&lat_at_units = "degrees_north" ; needed for plotting in NCL
   new_data&lon_at_units = "degrees_east"
   in->prate_regrid = new_data
end

Adam

Adam Phillips wrote:
> Hi Sara,
>
> When using the addfile option "w", you cannot read a variable out of the
> file with lat/lon dimensions 94x192 and write a variable back into the
> file with the exact same name with different dimensions. You need to
> write the variable to the file under a different variable name.
>
> I also made some changes to your linint2_Wrap line:
>
> begin
> in = addfile("prate_media2.nc", "w")
> data = in->prate
> new_lon = fspan(1.25, 358.75, 144)
> new_lat = fspan(88.75, -88.75, 72)
> new_data = linint2_Wrap(data&lon,data&lat,data,True,new_lon,new_lat,0)
>
> new_data!0 ="lat"
> new_data!1 = "lon"
> new_data&lat = new_lat
> new_data&lon = new_lon
> new_data&lat_at_units = "degrees_north" ; needed for plotting in NCL
> new_data&lon_at_units = "degrees_east"
> in->prate_regrid = new_data
> end
>
> Good luck,
> Adam
>
> Sara Reis wrote:
>> Hi, NCL users!
>>
>> I need to convert a data type of an archive "prate_media2.nc" with not
>> constant resolutions (specified below) for the resolution of 2,5x2,5
>> (LATITUDE = 88.75, 86.25, 83.75,...,-83.75, -86.25, -88.75 and
>> LONGITUDE = 1.25, 3.75, 6.25,...,353.75, 356.25, 358.75).
>>
>> At archive "prate_media2.nc", the lat has 94 values and the lon has
>> 192 values.
>> I want the new lat with 72 values and the new lon with 144 values
>> (because of the new resolution).
>>
>> My script...
>>
>> begin
>>
>> in = addfile("prate_media2.nc", "w")
>> data = in->prate
>>
>> new_lon = fspan(1.25, 358.75, 144) new_lat = fspan(88.75, -88.75,
>> 72)
>> new_data =
>> linint2_Wrap(data&lon,data&lat,inmatrix,True,new_data,new_data,0)
>>
>> new_data!0 ="lat"
>> new_data!1 = "lon"
>> new_data&lat = new_lat
>> new_data&lon = new_lon
>>
>> in->prate = new_data ; THE PROBLEM IS HERE
>>
>> end
>>
>> THE LAT AND LON OF THE ARCHIVE ".nc":
>> lat = 88.542, 86.6531, 84.7532, 82.8508, 80.9473, 79.0435, 77.1394,
>> 75.2351,
>> 73.3307, 71.4262, 69.5217, 67.6171, 65.7125, 63.8079, 61.9033,
>> 59.9986,
>> 58.0939, 56.1893, 54.2846, 52.3799, 50.4752, 48.5705, 46.6658,
>> 44.7611,
>> ...
>> -67.6171, -69.5217, -71.4262, -73.3307, -75.2351, -77.1394,
>> -79.0435,
>> -80.9473, -82.8508, -84.7532, -86.6531, -88.542 ;
>>
>> lon = 0, 1.875, 3.75, 5.625, 7.5, 9.375, 11.25, 13.125, 15, 16.875,
>> 18.75,
>> 20.625, 22.5, 24.375, 26.25, 28.125, 30, 31.875, 33.75, 35.625, 37.5,
>> 39.375, 41.25, 43.125, 45, 46.875, 48.75, 50.625, 52.5, 54.375,
>> 56.25,
>> ...
>> 331.875, 333.75, 335.625, 337.5, 339.375, 341.25, 343.125, 345,
>> 346.875,
>> 348.75, 350.625, 352.5, 354.375, 356.25, 358.125 ;
>>
>> Can`t I do this?
>>
>> Thaks a lot...
>>
>> Sara
>>
>> __________________________________________________
>> Fale com seus amigos de graça com o novo Yahoo! Messenger
>> http://br.messenger.yahoo.com/
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 08 2007 - 15:03:02 MST

This archive was generated by hypermail 2.2.0 : Mon Mar 12 2007 - 11:26:34 MDT