[Thread Prev][Thread Next][Index]
Re: [ferret_users] Store an array of georeferenced values for climate model : Masking
Hi Eowyn,
You can set up a variable in Ferret and use it to define a set of masks
that can be combined to form the mask you want. Use the same grid as the
climate model. It's a little tedious, but not too hard, really.
You could use the grid from your climate model, or just define axes
having the same grid. For example,
yes? define axis/x=1:360:1/units=degrees/modulo xlon
yes? define axis/y=-90:90:1/units=degrees ylat
Then define a set of masks. I'll define them to have values of 1 or 0,
and then at the end these can be used to define your regions with the
values N=300 or N=100. Remember that adding two masks gets us an OR
operation (mask1 or mask2) , and multiplying gets an AND (mask1 and
mask2). Try this and you'll see how it goes.
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 testvar = 1+0*var_from_file
using x[gx=testvar] etc below)
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!!
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Privacy Policy | Disclaimer | Accessibility Statement