[Thread Prev][Thread Next][Index]

Re: [ferret_users] fill_between a curve and a constant line



Hi Jennifer,
Did Jagadish's reply answer the question? Just to add one thing: If you need a variable with the same axis as your original variable but with the constant value of 29 or whatever,

  let const_linearray29 = 29 + 0*temp_month

However the fill_between lets you just give a number and it'll fill between that constant number and the curve.   So you should just be able to say
go fill_between poly/over/nolabel/palette=red temp_month t_historical  29

go fill_between poly/over/nolabel/palette=blue temp_month t_historical 27

Looking at the example at the start of the fill_between script:

yes? go/help fill_between 
! ...

yes? define axis/t=1-jan-1990:1-mar-1990:1/unit=days tday
yes? let a = SIN(T[gt=tday]/10)
yes? let b = 0.4*cos(T[gt=tday]/4) - 2
yes?  plot a, b
yes? go fill_between poly/over/palette=blue b tday -1.2


On 9/3/2012 1:29 AM, jagadish karmacharya wrote:
Hi,

Do you want to plot color lines or filled plot. In any case, you can get desired result if you define a mask. Here is what I would do:

! Define mask
let t_hi=if temp_month gt 29 then temp_month
let t_lo=if temp_month lt 27 then temp_month

! line plot
plot temp_month        ! if you don't want the line with values between 26-29 to appear you can use /color=white qualifier here
plot/ov/color=red t_hi
plot/ov/color=blue t_lo

! fill in plot
plot temp_month
go plot_swath poly/ov/nolab/pal=red t_hi 29        ! here you can use fill_between  as well but you have to insert x axis (time axis here) name in between
go plot_swath poly/ov/nolab/pal=blue t_lo 27

Hope this helps.
 
Jagadish


From: "Jennifer.Abernethy@xxxxxxxx" <Jennifer.Abernethy@xxxxxxxx>
To: ferret_users@xxxxxxxx
Sent: Monday, September 3, 2012 6:52 AM
Subject: [ferret_users] fill_between a curve and a constant line

Hi,

New to ferret here. I have 40 years of monthly sst data at a specific lat/lon that moves between 26C and 30C. I want to color in the times it's above 29C red, and the times it's below 27C blue. I don't want anything else colored in. 

I tried the fill_between script, but when used with a curve and a constant value, it colors in the curve above and the 'negative' space below the constant value, which is not what I want at all. (http://ferret.pmel.noaa.gov/Ferret/faq/fill-between-two-curves).

How might I do this?
To complicate things, the x axis is a time axis.
I've tried a few different things, and I think I'm stumped now at the point of defining the straight, constant lines as  'curves' themselves to refer to in the fill_between command.  But I can't find how to define an constant array without typing in all 480 values manually (http://ferret.pmel.noaa.gov/static/Demos/constant_array_demo/constant_array_demo.html), or how to @asn it to a time axis so it will plot with the sst data.


here's the monthly data and axis definitions:

use "enso_indices/stsu.nc"
define axis/units=days/t="1-jan-1970":"31-dec-2009":1/edges/cal=gregorian t_daily
define axis/edges/units=days/t0=1-jan-1900/cal=gregorian t_mon_historical = days1900(year,month,1)
let temp = tsu[x=130,y=-12]    !long, lat
let temp_daily = temp[gt=t_daily@asn] 
let temp_month = temp_daily[gt=t_historical@ave]  !monthly averages

I guess I'd want a variable the same format as temp_month (40yrs of monthly values), but all values are 29 (and another variable where all values are 27)...?
Then I could use the fill_between command with the args curve, axis, curve:
go fill_between poly/over/nolabel/palette=red temp_month t_historical const_linearray29
go fill_between poly/over/nolabel/palette=blue temp_month t_historical const_linearray27

maybe there's a much better way to do this.....
could some wonderful ferret expert please help me fill in the blanks?

thanks,
jenny




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

Privacy Policy | Disclaimer | Accessibility Statement