**To**:**Eowyn.Connolly-Brown@xxxxxxxx****Subject**:**Re: [ferret_users] Store an array of georeferenced values for climate model : Masking****From**:**Ansley Manke <ansley.b.manke@xxxxxxxx>**- Date: Thu, 04 Jun 2009 15:47:44 -0700
- Cc: oar.pmel.ferret_users@xxxxxxxx
- In-reply-to: <c4a5b0a0c3ee355.4a27eb5b@xxxxxxxx>
- References: <c4a5b0a0c3ee355.4a27eb5b@xxxxxxxx>
- Sender: owner-ferret_users@xxxxxxxx
- User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Hi Eowyn,

yes? define axis/x=1:360:1/units=degrees/modulo xlon yes? define axis/y=-90:90:1/units=degrees ylat

define axis/x=1:360:1/units=degrees/modulo xlon define axis/y=-90:90:1/units=degrees ylat let testvar = 1 + 0*x[gx=xlon] + 0*y[gy=ylat] ! apply the mask to this (Or start with a file: use my_data.nc

let Alon1 = if x[gx=xlon] gt 20 then 1 else 0 let Alon2 = if x[gx=xlon] lt 120 then 1 else 0 let Alat1 = if y[gy=ylat] gt -60 then 1 else 0 let Alat2 = if y[gy=ylat] lt -20 then 1 else 0 let Alonmask = Alon1 * Alon2 let Alatmask = Alat1 * Alat2 let Alonlatmask = Alonmask* Alatmask ! creates a 2-D mask shade Alonlatmask * testvar; pause ! to check what you've done let Blon1 = if x[gx=xlon] gt 120 then 1 else 0 let Blon2 = if x[gx=xlon] lt 145 then 1 else 0 let Blat1 = if y[gy=ylat] gt -10 then 1 else 0 let Blat2 = if y[gy=ylat] lt 20 then 1 else 0 let Blonmask = Blon1 * Blon2 let Blatmask = Blat1 * Blat2 let Blonlatmask = Blonmask* Blatmask shade Blonlatmask * testvar; pause shade (Alonlatmask+Blonlatmask) * testvar; pause ! both rectangles let Clon1 = ... ! And so forth. When all done, add them all up, and where the ! sum > 0 the mask is your value of 300, else 100. This works ! even if some of the rectangles overlap each other. LET all_mask = if (Alonlatmask+Blonlatmask+...) GT 0 then 300 else 100 ! Multiply by test_var to define the final mask over the whole grid: shade all_mask * testvar; pause LET n = all_mask * testvar save/file=mask_file.nc n Eowyn.Connolly-Brown@xxxxxxxx wrote:

Greetings!I have searched the mail archives, but have been unable to find a solution to my problem.I want to create a netCDF file that contains an array of values that are referenced by latitude and longitude. Specifically, I have 4 regions in which I want to set N=300 and set N=100 otherwise. This array will then be supplied to a climate model.The mask=if ... else command would be perfect, except it requires me to already have a data set from which I take a variable to analyze. The set region/x=/y= command would be perfect, except you can't "add" nonadjacent regions the way you can add masks.Has anyone done this before?Thank you very much!!

**References**:**[ferret_users] Store an array of georeferenced values for climate model***From:*Eowyn . Connolly-Brown

- Previous by thread:
**[ferret_users] Store an array of georeferenced values for climate model** - Next by thread:
**[ferret_users] Extend non-modulo axis to modulo**

Contact Us

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement