[gradsusr] lterp+sdfwrite adding extra longitude values

Andrew Friedman andfried at berkeley.edu
Thu Sep 5 19:59:58 EDT 2013


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





More information about the gradsusr mailing list