[Thread Prev][Thread Next][Index]

Re: [ferret_users] india boundary



Hi -
Glad to hear you got the pt_in_poly function working to create a mask. I don't really see a way to use that to include or exclude portions of grid cells, but you could use Ferret to define and regrid your variable to a finer grid, before applying the boundary mask. This is always the nature of working with gridded data - the variable which is defined on the grid takes on its value within the grid cells.

You can use your masked variable in calculations as well as graphics, if you define the mask as shown in the example for pt_in_poly -- then the variable is valid inside the boundary and missing outside.
let aoi_india = if pt_in_poly(aoi_var, xp, yp) gt 0 then 1
I'm not sure what you mean by zooming in.  You can do graphics or calculations on any region in your grid by specifying that XY region.

To overlay shapes, probably the easiest way is to use the "go polymark" script.  A simple map plot:

yes? use etopo05
yes? shade/x=40:120/y=0:40/lev=c/pal=dark_land_sea rose
yes? go polymark poly/over/nokey/nolab/pal=pink 72.75, 19, " ", square


Thanks for the reminder about 2012. We'll get that set up.

Ansley

On 2/14/2012 9:48 AM, jagadish karmacharya wrote:
Hi,

Thanks, I have installed version 6.72 and successfully used pt_in_poly function to creat mask for AOI. This acts on whole grid (As ittustrated in example, either grid is included or excluded) that is great but is there a way to create mask that exactly match say a country boundary (i.e grids at boundary are partitioned according to geographic boundary)?  I am asking this, because I once had to compute basin average temperature to input in hydrological model and I ended up doing manual calculation considering approximate fraction of grid laying within basin boundary. Using Patrick's method, I can think of a way to plot it by masking/whiteout the regions surrounding AOI but this would not work for mathmatical computation.

Further, I was wondering using Patrick's method i)  how to zoom into AOI as well as plot the AOI only, ii) how to create mask for say a state India using IND_adm1.nc. I have found ways for both, incase anyone is interested.

On seperate note: I want to overlay circle/ square as shown in the bottom right plot/command at http://ferret.pmel.noaa.gov/Ferret/faq/ferret-color-palettes but it doesn't work. I suspect some lines/ definitions are missing

ps : Its about time 2012 archive in created in email archives

Best regards,
 
Jagadish



From: Ansley Manke <ansley.b.manke@xxxxxxxx>
To: jagadish karmacharya <j_karmacharya@xxxxxxxxx>
Sent: Wednesday, February 8, 2012 5:28 PM
Subject: Re: [ferret_users] india boundary

Hi,
You can get the Ferret executables tar file from the downloads pages,
http://ferret.pmel.noaa.gov/static/Downloads/ferret_downloads.html

and install it in a local directory of your own. If you don't know which one to try, we can tell which you have now using the header information from your current Ferret, that is, when you start Ferret, you get some lines like this:

> ferret
        NOAA/PMEL TMAP
        FERRET v6.65 
        Linux rh5 (gfortran) 2.6.18-164.11.1.el5 - 11/17/10
         8-Feb-12 08:40    

This is the RedHat 5, 32-bit one.  Or

> ferret
        NOAA/PMEL TMAP
        FERRET v6.65 
        Linux(gfortran) 2.6.9-89.0.20.ELsmp - 11/17/10
         8-Feb-12 08:40    

This is the RedHat 5, 64-bit one.   If it's not one of these, send me what does come up when you start Ferret and we can go from there.

Get the executables tar file, fer_executables.tar.gz, and put it in your directory.  I might make one that says,

/home/users/ansley/ferret/

and then go into that directory,

> tar xzf fer_executables.tar.gz

In the bin/ directory, you will find the Ferret executable, ferret (synbolic-linked to ferret_v6.72)

So I could just run
/home/users/ansley/ferret/bin/ferret_v6.72

The environment that you have set up for v6.65 should work fine with this executable.

Ansley

On 2/8/2012 8:35 AM, jagadish karmacharya wrote:
Hi Ansley,

Mine is version 6.5.

I have to ask system administrator for the update but that could take ages. Is it possible to install/load it in the version I am currently using?

Thanks
 
Jagadish


From: Ansley Manke <ansley.b.manke@xxxxxxxx>
To: jagadish karmacharya <j_karmacharya@xxxxxxxxx>
Cc: "ferret_users@xxxxxxxx" <ferret_users@xxxxxxxx>
Sent: Wednesday, February 8, 2012 4:15 PM
Subject: Re: [ferret_users] india boundary

Hi Jagadish,
The function pt_in_poly is included with Ferret versions 6.67 and higher.  Perhaps you have an older Ferret version?  Can you update your Ferret executable?

Ansley

On 2/8/2012 4:59 AM, jagadish karmacharya wrote:
Hi Patrick and Ansley,

Thanks a lot but I am a bit confused. My guess is direct application of Patrick's methode would be mask (white out) unwanted regions surrounding Area Of Interest (AOI) that a mask of AOI itself. However, method mentioned by Ansley should make suppliment it and make it possible to creat a mask for AOI upon which averages etc. could also be computed.

Well, I followed the steps mentioned by Patrick ( took a while to figure out, plot.jnl is the script he has written in this mail) for NPL_adm0. Firstly, margins_set.jnl script is missing in my case, so at first I just disabled that line. This produced the filled map for Nepal with seemed OK. Next I replaced the margins_set.jnl script with margins.jnl; but this time filled map and the boarder outline does not overlay. Does is makes any difference? the resulting nc file seems to overlay correctly (with both plot/vs and polygen) when I tried it over another dataset (as well as match with go land overlay. 

Furhter, Patrick, what do you mean by: " .... just do not blindly use polygon command but rather plot/vs. There may be a problem anyway."

My prime interest is to creat a mask for AOI, but I can't find pt_in_poly function (It is not listed when I issue show function command). Can someone send me a copy?

Thanks in advance.

Jagadish


From: Ansley Manke <ansley.b.manke@xxxxxxxx>
To: Brockmann Patrick <Patrick.Brockmann@xxxxxx>
Cc: nitin patil <nitinpatil85@xxxxxxxxx>; ferret_users@xxxxxxxx
Sent: Tuesday, February 7, 2012 10:43 PM
Subject: Re: [ferret_users] india boundary

Hi
Thank you for that resource, Patrick.

Once you have the outline and have verified it using PLOT/VS, Patrick's message shows how to use the POLYGON command to plot the shape.  Another option is the function pt_in_poly,
http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/appendix-a-external-functions/pt_in_poly/

which would let you make a mask which is 1 at every grid location inside the polygon and missing outside it; so you could do calculations or graphics over only the region inside the border.

Ansley

On 2/7/2012 11:29 AM, Brockmann Patrick wrote:
> nitin patil a écrit :
>> Dear ferret users,
>>                            Did any one knows how to give a border to India country if we have to plot only India.
>> if possible can we  border states also?
>
> Hi,
>
> I have done this recently using kml files distributed
> by the "Global Administrative Areas" website.
>
> Please follow the different steps:
>
> 1) From http://www.gadm.org
> Go in the Download section, select the country
> and choose "Google Earth .kmz"
>
> After the download, you can have a look to the kmz file
> with googleearth of course.
> Unzip the kmz file. You should obtain a kml file.
>
> 2) Convert the kml file to a text with
> 3 columns lon,lat,number (number is the
> index representing the area) with the python
> script attached.
>
> 3) Use the ferret plot.jnl script to validate and
> save the polygons as a netcdf file.
>
> Here is an example with India with the first
> 2 administratives levels.
>
> $ unzip IND_adm1.kmz
> $ ./convert_kml.py IND_adm1.kml > IND_adm1.dat
> $ ferret
> yes? go plot.jnl IND_adm1.dat IND_adm1.nc
>
> Note: that when I try to do the same with IND_adm0.dat,
> ferret restarts my X11 server !
> The problem occurs at line
> repeat/name=n/range=1:`numb[i=@max]` ( def sym n=`n` ; let lon1=if numb eq `n` then lon ; let lat1=if numb eq `n` then lat ; polygon/line/fill/o/nolab/lev=(1,200,1)/pal=thirty_by_levels.spk lon1,lat1,`n` ; PPL SHASET RESET )
>
> But the method is still ok, just do not not blindly
> use polygon command but rather plot/vs.
> There may be a problem anyway.
>
> Happy ferreting
>
> Patrick
>







[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement