[gradsusr] Combining .NC files

Andrew Revering andy at f5data.com
Sat Oct 23 23:37:46 EDT 2010


- I am opening a .NC file, setting the coordinates using set lat & set lon
to a small portion of the entire grid, then capturing that area into a
variable.

- I then capture the full .NC domain into another variable.

- I manipulate the smaller subsection, then combine the two back into one
.NC file.

 

This seems to work. 

 

However, the problem is when I try to take two of these modified files and
combine THEM together. When I do this I get an error that looks similar to:

 

grid[1]'s size = 1818240

max grid[2]'s size = 19175612

grid[3]'s size = 1818240

max grid[2]'s size = 19175612

size incompatible

 

Now if I just take two .NC files and combine them it works without error.
The problem is when I modify the files as outlined in the 3 steps I outlined
above, and then combine the two files together.

 

Any ideas as to what is causing the problem? Below is my script. I assume my
problem is somewhere in the 'clutterf' function.

 

--------------------------------------------------------

 

function composite()

 

* Fresh start

* -----------

  'reinit'

 

* Add contribution of each site

* -----------------------------

accumsite(kabr,1)

accumsite(kabx)

 

*  Must have at least 1 file open

   'sdfopen C:\nexrad\out\sn.kabr.nc'

   'set lon -135 -64'

   'set lat 20 55'

 

* Save the composite to a netcdf file

  'set sdfwrite C:\nexrad\radar_composite1.nc'

  'sdfwrite mv'

 

*  'quit'

 

#-----------------------------------------

 

function accumsite(site,init)

 

*PERFORM THE CLUTTER FILTER

clutterf(site)

 

* Open a NetCDF file of radar data

 say 'working on out/sn.' site '2.nc'

 'sdfopen C:\nexrad\out\sn.' site '2.nc'

 

* Set domain of interest

  'set lon -135 -64'

  'set lat 20 55'

 

* value on reference grid

***'define v = re(value,0.013599)'

  'define v = re(outval,0.037)'

 

* Now accumulate all radar sites together (+), which includes adding the
same value for the same grid point if there is overlap.

if (init=1) 

    'define mv = const(v,0,-u)'

else

    'define mv = if(const(v,0,-u),>,mv,const(v,0,-u),mv)'   

endif

 

* close the file

  'close 1'

 

return

 

 

*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''

*'''''''''''''''''''''''''''''''''GROUND CLUTTER
FILTER''''''''''''''''''''''''''''''''''''''

*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''

 

function clutterf(site)

 

*OPEN A NetCDF FILE OF RADAR DATA.

'sdfopen C:\nexrad\out\sn.'site'.nc'

 

*GET THE COORDINATES OF THE RADAR SITE

If (site=kabr)

  _site.lat = 45.4558

  _site.lon = -98.4131

endif

 

If (site=kabx)

  _site.lat = 35.1497

  _site.lon = -106.82389

endif

 

*SET THE DBZ THRESHOLD TO FILTER OUT WITHIN OUR GROUND CLUTTER AREA

mindbz = 26

 

*SET THE RADIUS OF THE GROUND CLUTTER AREA.

'set lat '_site.lat - 1.4' '_site.lat + 1.4

'set lon '_site.lon - 1.9' '_site.lon + 1.9

 

*PUT A COPY OF THE GRID INTO ITS OWN GRID ARRAY TO FILTER GROUND CLUTTER

'define inner = value'

 

*NOW COMBINE THE FULL RADAR SCOPE WITH THE MODIFIED GROUND CLUTTER SECTION

* Set domain of interest

  'set lon -135 -64'

  'set lat 20 55'

 

*ANY VALUES LESS THAN mindbz DBZ WE ASSUME IS GROUND CLUTTER...SET TO ZERO

*FORMAT IS...IF FIRST > MV THEN FIRST, ELSE MV

'define mv = if(const(inner,0,-u),<,'mindbz',0,const(inner,0,-u))'

 

* Now accumulate full scope with edited ground clutter (+), which includes
adding the same value for the same grid point if there is overlap.

*INITIALLY WE SET THE REPLACEMENT VALUE TO 99 SO THAT WHEN WE COMBINE WITH
THE BIG SCOPE, WE REPLACE THOSE 99 (NULL) POINTS WITH REAL REFLECTIVITY
OUTSIDE OF THE 

*INNER GROUND CLUTTER SCOPE.

'define mv2 = const(mv,99,-u)'

'define outval = if(const(mv2,0,-u),>,value,value,const(mv2,0,-u))'

'define value = outval'

 

*CLOSE THE FILE

'close 1'

 

* Save the composite to a netcdf file

  'set sdfwrite C:\nexrad\out\sn.'site'2.nc'

  'sdfwrite value'

 

return

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20101023/3087a6d0/attachment-0003.html 


More information about the gradsusr mailing list