[gradsusr] fwrite gridding issue
Eric Altshuler
ela at cola.iges.org
Thu May 10 16:22:51 EDT 2012
Tom,
Meridional wraparound does not occur in grads. However, if the latitude range of your data is not exactly -90 to 90, then it's best to use 'set y 1 YSIZE' rather than 'set lat -90 90'. An example of this is if you have a gaussian grid, which does not include the poles. In this case, if you set the latitude range to be -90 to 90, you may get unwanted rows of missing data near the poles.
In your case, you have a 144x73 grid which I assume is a global 2.5 degree grid that does include the poles, so the effect of 'set lat -90 90' and 'set y 1 73' will be the same. You might as well go ahead and use the following:
'set x 1 144'
'set y 1 73'
Eric
----- Original Message -----
From: "Thomas Robinson" <ter at hawaii.edu>
To: "GrADS Users Forum" <gradsusr at gradsusr.org>
Sent: Thursday, May 10, 2012 3:31:00 AM
Subject: Re: [gradsusr] fwrite gridding issue
Aloha Eric,
Thank you for your input. The issue I seem to be having is with meridional wrap around also. Does GrADS have the same behavior for the y coordinate and will something similar (ie 'set y 1 YSIZE') work as well? Should I not use set lat and set lon, but use 'set y 1 YSIZE' and 'set x 1 XSIZE' instead when I do my fwrite?
This takes about four and a half days to run, so if I have to rerun it I want to make sure I have everything set correctly.
-Tom
On Wed, May 9, 2012 at 6:58 PM, Eric Altshuler < ela at cola.iges.org > wrote:
Tom,
There are several possible causes for the problem you're describing, but I suspect it is due to the wraparound behavior in grads when you have global data and your longitude range is 0-360 (or -180 to 180, etc.) In this situation, if the number of longitudes in your dataset is XSIZE, fwrite will write XSIZE+1 columns (longitudes) of data to the output file, with the last column being a duplicate of the first one (X=1). To get around this behavior, replace your 'set lon 0 360' command with the following:
'set x 1 XSIZE'
where XSIZE is the number of longitudes specified in the xdef line of your ctl file. Now, fwrite will write XSIZE columns of data instead of XSIZE+1.
If this change doesn't fix your problem, there may be a bug in your fortran code. Also, if your fortran code writes the output file using sequential access, your ctl file for the output data needs to include 'options sequential'.
Best regards,
Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA
E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793
----- Original Message -----
From: "Thomas Robinson" < ter at hawaii.edu >
To: "GrADS Users Forum" < gradsusr at gradsusr.org >
Sent: Wednesday, May 9, 2012 11:35:59 PM
Subject: [gradsusr] fwrite gridding issue
Aloha,
I used fwrite to write out to a binary file in order to create a large file with about 48000 time steps for global data (because I am crazy). I noticed that when I use fortran to create a new data file that has all 48000, it doesn't match with what the original data plotted, instead it seems skewed. No manipulations were done to the data, it was just read it all in and write it out. When I tried to loop the data, I further noticed that the northern border looped around the south and then moved upwards back to the north. It just keeps looping around and it's odd because the top boundary of the map isn't continuous with the bottom boundary (unlike the side boundaries which are continuous). Anyways, I am wondering why this happened and what I can do to make it work out correctly.
Here is my fwrite code. it is the first time step, nt is the last time step, chi is the velocity potential that was calculated using 'define chi = fish_chi(UGRDprs,VGRDprs)' :
*# set up global domain
'set lev 200 '
'set lat -90 90'
'set lon 0 360'
*#**************************************************************
say 'write data out to binary file called CHI.200hPa'filenum'.dat'
'set fwrite -le -sq -cl CHI_200hPa_'filenum'.dat'
'set gxout fwrite'
while (it <= nt)
'set t 'it
'display chi'
it=it+1
endwhile
'disable fwrite'
Mahalo for your help!
-Tom
--
Tom Robinson
President Graduate Student Organization
Student Caucus Representative for the Graduate Student Organization
Graduate Student - Department of Meteorology
732-718-2323
_______________________________________________
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
--
Tom Robinson
President Graduate Student Organization
Student Caucus Representative for the Graduate Student Organization
Graduate Student - Department of Meteorology
732-718-2323
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr
More information about the gradsusr
mailing list