[gradsusr] lterp+sdfwrite adding extra longitude values

Jennifer Adams jma at cola.iges.org
Thu Sep 5 20:57:47 EDT 2013


I updated the lterp() doc page with some more examples, including an override for the time dimension -- for when the times of the source and destination grids don't match. Below, I also cite some highly relevant information about the dimension environment and the default file from the doc page on variables:

The complete specification for a variable name is:
abbrev.file#(dimexpr,dimexpr,...)    where:

abbrev   is the abbreviation for the variable as specified in the data descriptor file 
file#    is the file number that contains this variable. If file# is absent, GrADS assumes the default file number. 
dimexpr  is a dimension expression that locally modifies the current dimension environment.
The dimexpr is used to override or modify the current dimension environment only for the abbrev variable. Only fixed dimensions can be modified with a dimexpr. The dimexpr can be given in grid or world coordinates. An important note: When you specify a dimension in grid units, GrADS always converts it to world coordinates. In general, this conversion is done using the scaling of the default file. The only exception to this rule is in this case, when a grid coordinate (x, y, z, t, or e) is supplied within a dimexpr as part of a variable specification. In the case of this special exception, the conversion is done using the scaling for the file that variable is to be taken from (i.e., file number file#). 

--Jennifer

On Sep 5, 2013, at 7:59 PM, Andrew Friedman wrote:

> Thanks to Jennifer and Chuck for your help.
> 
> I was able to use method 2 from Jennifer's email below.
> The only other issue I ran into is that I needed to set the time coordinates of my coarse grid file the same as the fine grid file.
> 
> Andrew
> 
> On Sep 4, 2013, at 2:59 PM, Jennifer Adams <jma at cola.iges.org> wrote:
> 
>> Hi, Andrew -- 
>> I agree that this is tricky, and I had recently updated the example in the docs to reflect the subtleties when using lterp with fwrite. I see I will have to add another example with sdfwrite -- this email has given me a good start on that ...
>> 
>> Anyway, the difference between your example and mine is that in my example the default file is the destination grid and in yours the default file is the source grid. It matters what file is set to be the default file because x=1:xsize resolves to different world coordinates when you change default files. The bottom line is you want to be constraining the coordinates of the destination grid. To fix your example, you have two options: 
>> 
>> 1. Switch the order of the sdfopen commands (i.e. open coarse.nc first), and then 'set x 1 number_of_points_in_coarse.nc' then change lterp command to lterp(fine.2,coarse)
>> 
>> 2. Before you define the output variable, you can 'set dfile 2' and then 'set x 1 number_of_points_in_coarse.nc' and then proceed. 
>> 
>> --Jennifer
>> 
>> On Sep 4, 2013, at 4:42 PM, Andrew Friedman wrote:
>> 
>>> Hi GrADS users,
>>> 
>>> I am using lterp to regrid a file to a coarser resolution, and saving the variable to netcdf using sdfwrite.
>>> 
>>> My problem is that the output file has 2 additional longitudes compared to the input grid destination description file.
>>> 
>>> Similar to the example in the lterp documentation in the grads index:
>>> 
>>> sdfopen fine.nc
>>> set X 1 [number of longitude points in fine.nc]
>>> sdfopen coarse.nc
>>> output = lterp(fine,coarse.2,aave)
>>> set sdfwrite output.nc
>>> sdfwrite output
>>> 
>>> I've had this issue before when there is just one input file, and explicitly defining longitude with the step 'set X 1 [number of longitude points]' works to solve it. In this case however, I'm not sure how to limit the longitude dimension of the output.
>>> Do you have ideas how I can fix this?
>>> 
>>> Thanks,
>>> Andrew
>>> 
>>> 
>>> ------
>>> Andrew Friedman
>>> Graduate Student, UC Berkeley Geography
>>> andfried at berkeley.edu
>>> 
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>> 
>> --
>> Jennifer M. Adams
>> Center for Ocean-Land-Atmosphere Studies (COLA)
>> 111 Research Hall, Mail Stop 2B3
>> George Mason University
>> 4400 University Drive
>> Fairfax, VA 22030 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
> 
> 
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer M. Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
111 Research Hall, Mail Stop 2B3
George Mason University
4400 University Drive
Fairfax, VA 22030 





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130905/fbb399ff/attachment-0003.html 


More information about the gradsusr mailing list