<div dir="ltr">I found the issue. So I produced a sample output of that file using the g2grb program to write out grib files from GrADS. From here, I use g2ctl to create a control file. It turns out I needed one more grid point longitudinally in my control file. I added that and it fixed the issue.<div><br></div><div><div>ydef 721 linear -90.00 0.25</div><div>xdef 1440 linear 0.00 0.25</div></div><div><br></div><div>should have been this:</div><div><br></div><div><div>ydef 721 linear -90.00 0.25</div><div>xdef 1441 linear 0.00 0.25</div></div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><b>-------</b></div>William (L.B.) LaForce IV<br>Meteorologist</div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 12, 2019 at 10:38 AM L.B. <<a href="mailto:bcbass2989@gmail.com">bcbass2989@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I've also attached a copy of the binary file and control file in case you would like to play around with it. The binary file contains just one timestep: 00Z01JAN <div><br clear="all"><div><div dir="ltr" class="gmail-m_8059216623470129733gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><b>-------</b></div>William (L.B.) LaForce IV<br>Meteorologist</div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 11, 2019 at 8:18 PM L.B. <<a href="mailto:bcbass2989@gmail.com" target="_blank">bcbass2989@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">I'm having an issue with a pesky control file that I created for a binary file that I wrote out with GrADS using the fwrite function.<div><br></div><div>I have a large dataset of multiple grib2 files containing 500mb Geopotential by year. I used templating in the control file to run through all the grib files. Here is the control file for that data:</div><div><br></div><div><div>dset ^ERA5_500GEO_%y4.grb2</div><div>index ^ERA5_500GEO_Climo.grb2.idx</div><div>undef 9.999E+20</div><div>options template</div><div>title ERA5_500GEO_Climo</div><div>* produced by g2ctl v0.1.4</div><div>* griddef=1:0:(1440 x 721):grid_template=0:winds(N/S): lat-lon grid:(1440 x 721) units 1e-06 input WE:NS output WE:SN res 48 lat 90.000000 to -90.000000 by 0.250000 lon 0.000000 to 359.750000 by 0.250000 #points=1038240:winds(N/S)</div><div><br></div><div>dtype grib2</div><div>ydef 721 linear -90.00 0.25</div><div>xdef 1440 linear 0.00 0.25</div><div>tdef 58440 linear 00Z01JAN1979 6hr</div><div>zdef 1 linear 1 1</div><div>vars 1</div><div>GP500mb 0,100,50000 0,3,4 ** 500 mb Geopotential [m^2/s^2]</div><div>ENDVARS</div><div><br></div><div>From here, I created a script to further reduce the size fo the climatology file by writing out to a binary file the average 500mb geopotential height every 6 hours for one year (data starts in 1979, but I started the script in 1980 to include a leap year to get Feb 29th - hence why I used 1461 for the first timestep).</div><div><br></div><div>The script that outputs the 6hour average is here:</div><div><br></div><div><div>'reinit'</div><div>'open ERA5_500GEO.ctl'</div><div>'set gxout fwrite'</div><div>'set fwrite 500HGT_Climo.dat'</div><div><br></div><div>tt=1461</div><div><br></div><div> while (tt<=2924)</div><div> 'set t 'tt</div><div> 'q dims'</div><div> rec=sublin(result,5)</div><div> vdate=subwrd(rec,6)</div><div> vday=substr(vdate,1,8)</div><div> say vday</div><div><br></div><div> if (vday=00Z29FEB | vday=06Z29FEB | vday=12Z29FEB | vday=18Z29FEB)</div><div> 'mean=(GP500mb(time='vday'1980)+GP500mb(time='vday'1984)+GP500mb(time='vday'1988)+GP500mb(time='vday'1992)+GP500mb(time='vday'1996)+GP500mb(time='vday'2000)+GP500mb(time='vday'2004)+GP500mb(time='vday'2008)+GP500mb(time='vday'2012)+GP500mb(time='vday'2016))/10'</div><div><br></div><div> else</div><div><br></div><div> 'mean=(GP500mb(time='vday'1979)+GP500mb(time='vday'1980)+GP500mb(time='vday'1981)+GP500mb(time='vday'1982)+GP500mb(time='vday'1983)+GP500mb(time='vday'1984)+GP500mb(time='vday'1985)+GP500mb(time='vday'1986)+GP500mb(time='vday'1987)+GP500mb(time='vday'1988)+GP500mb(time='vday'1989)+GP500mb(time='vday'1990)+GP500mb(time='vday'1991)+GP500mb(time='vday'1992)+GP500mb(time='vday'1993)+GP500mb(time='vday'1994)+GP500mb(time='vday'1995)+GP500mb(time='vday'1996)+GP500mb(time='vday'1997)+GP500mb(time='vday'1998)+GP500mb(time='vday'1999)+GP500mb(time='vday'2000)+GP500mb(time='vday'2001)+GP500mb(time='vday'2002)+GP500mb(time='vday'2003)+GP500mb(time='vday'2004)+GP500mb(time='vday'2005)+GP500mb(time='vday'2006)+GP500mb(time='vday'2007)+GP500mb(time='vday'2008)+GP500mb(time='vday'2009)+GP500mb(time='vday'2010)+GP500mb(time='vday'2011)+GP500mb(time='vday'2012)+GP500mb(time='vday'2013)+GP500mb(time='vday'2014)+GP500mb(time='vday'2015)+GP500mb(time='vday'2016)+GP500mb(time='vday'2017)+GP500mb(time='vday'2018))/40'</div><div><br></div><div> endif</div><div><br></div><div> 'd mean/9.80665'</div><div><br></div><div> tt=tt+1</div><div> endwhile</div><div><br></div><div>'disable fwrite'</div></div><div><br></div><div>The control file for this binary file named: 500HGT_Climo.dat is where I am having the issue. The control file is below:</div><div><br></div><div><div>dset ^500HGT_Climo.dat</div><div><br></div><div>title ERA5 500 hPa Height Climatology 1979 to 2018</div><div>undef 9.999E+20</div><div><br></div><div>ydef 721 linear -90.00 0.25</div><div>xdef 1440 linear 0.00 0.25</div><div>tdef 1464 linear 00Z01JAN1980 6hr</div><div>zdef 1 linear 1 1</div><div>vars 2</div><div> hgt500mean 1 99 500 hPa Mean Geopotential Height [gpm]</div><div>ENDVARS</div></div><div><br></div><div>If I were to just plot the first timestep from this binary file, I would get the first image attached named: 'fromdatfile.png'. This image is wrong, however. The correct one (attached) is named: 'fromscript.png'. I can run that same 6 hour average script but change it to output a contoured image, and it is correct (the output is the 'fromscript.png' image). However, that same exact code, when written to binary format and then plotted is wrong. Somehow the control file is messing up, but I cannot figure out where.</div><div><br></div><div>I have tested the 6hour average script using a smaller domain than global (just the US) and adjusted the control file accordingly and it works fine, but the full global domain doesn't want to plot correctly with that control file. Any ideas on what might be going on? Thanks!</div><div><div dir="ltr" class="gmail-m_8059216623470129733gmail-m_150694054350638994gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><b>-------</b></div>William (L.B.) LaForce IV<br>Meteorologist</div></div></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div>