CDAT / vcs

Visualization Control System
19 stars 13 forks source link

streamlines #269

Closed doutriaux1 closed 6 years ago

doutriaux1 commented 7 years ago
import vcs
import cdms2
import os
f= cdms2.open(os.path.join(cdat_info.get_sampledata_path(),"clt.nc"))
u=f("u")
v=f("v")
x=vcs.init()
st = vcs.createstreamline()                                                                   
x.plot(u(latitude=(-10,10),longitude=(-120,-95)),v(latitude=(-10,10),longitude=(-120,-95)),st)
x.png("blah")

blah

aashish24 commented 7 years ago

did it broke recently?

danlipsa commented 7 years ago

@doutriaux1 Try setting gm.startseed to be inside the domain.

doutriaux1 commented 7 years ago

that did it!

st.startseed = [-100,0,0]

@danlipsa we should default it to None and manually pick a point inside the domain

doutriaux1 commented 7 years ago

@danlipsa it's probably worth explaining in your notebook tutorial

potter2 commented 7 years ago

I still don't get any streamlines.

import cdms2
import vcs
f1=cdms2.open('uas_6hr_reanalysis_CFSR_1998010100-1998123118.nc')
f2=cdms2.open('vas_6hr_reanalysis_CFSR_1998010100-1998123118.nc')
u=f1('uas',time=('1998-10-27','1998-10-29'),lat=(12,16),lon=(-96,-82))
v=f2('vas',time=('1998-10-27','1998-10-29'),lat=(12,16),lon=(-96,-82))
#u=f1('uas',time=('1998-10-27','1998-10-29'))
#v=f2('vas',time=('1998-10-27','1998-10-29'))
x=vcs.init()
gm=x.createstreamline()
gm.evenlyspaced = False         # only available on releases after 2.10 or on the nightly packages.
# streamlines are colored by vector magnitude
gm.coloredbyvector = True
# We want 10 glyphs(arrows) per streamline
gm.numberofglyphs = 10
gm.filledglyph = True
# we place 400 random seeds in a circle that covers the data. This means fewer seeds will be inside the data.
# The number of seeds inside the data will result in streamlines.
gm.numberofseeds = 400
gm.evenlyspaced = True # only available only on releases > 2.10 or on the nightly packages
# We want the streamline to be about one cell apart from each other
gm.separatingdistance = 1
# The seed for the first streamline. All other seeds are generated automatically
gm.startseed = [-90, 0, 0]
# create an evenly spaced streamline plot
x.plot(u, v, gm, bg=1)
doutriaux1 commented 7 years ago

@potter2 you need to get a pint within your domain gm.startseed = [-90, 0, 0] has a lat of 0 which is outside of your domain you want gm.startseed = [-90, 14,0] # [x,y,z]

potter2 commented 7 years ago

got it. Thanks now it works

danlipsa commented 7 years ago

@doutriaux1 None for startseed is a good idea. This way I can leave the value as is if the user sets it. We should do that.

danlipsa commented 7 years ago

... If the value is None, we ca set it in the middle of the domain.

potter2 commented 7 years ago

honduras

How do I fix the endpoints of the color bar and the colors? I know this is because of the matplotlib color maps but I just want one of the vcs colormaps.

doutriaux1 commented 7 years ago

which colormap are you using? is it an "old" vcs colormap with reserved colors from 240 to 256?

if so

import vcs
vcs.utils.defaultColorRange = range(16,240)
potter2 commented 7 years ago

Yes, the old one,. this doesn't work, I still get the blank on each end

sorry to be so dense on this: import cdms2 import vcs vcs.utils.defaultColorRange=range(16,240) f1=cdms2.open('uas_6hr_reanalysis_CFSR_1998010100-1998123118.nc') f2=cdms2.open('vas_6hr_reanalysis_CFSR_1998010100-1998123118.nc') u=f1('uas',time=('1998-10-29','1998-10-29','cob'),lat=(12,24),lon=(-96,-82)) v=f2('vas',time=('1998-10-29','1998-10-29','cob'),lat=(12,24),lon=(-96,-82)) u=u/.44704 v=v/.44704

u=f1('uas',time=('1998-10-29','1998-10-29'))

v=f2('vas',time=('1998-10-29','1998-10-29'))

x=vcs.init() x.setcolormap("rainbow")

u.units='mph'

gm=x.createstreamline() gm.evenlyspaced = False # only available on releases after 2.10 or on the nightly packages.

streamlines are colored by vector magnitude

gm.coloredbyvector = True

We want 10 glyphs(arrows) per streamline

gm.numberofglyphs = 10 gm.filledglyph = True

we place 400 random seeds in a circle that covers the data. This means fewer seeds will be inside the data.

The number of seeds inside the data will result in streamlines.

gm.numberofseeds = 400 gm.evenlyspaced = True # only available only on releases > 2.10 or on the nightly packages

We want the streamline to be about one cell apart from each other

gm.separatingdistance = 1

The seed for the first streamline. All other seeds are generated automatically

gm.startseed = [-90.0, 14.0, 0]

create an evenly spaced streamline plot

x.plot(u, v, gm, bg=1,continents=4,ratio="auto")

x.plot(u, v, gm, bg=1)

x.png('/home/potter/Desktop/honduras1.png')

potter2 commented 7 years ago

I'm trying to make a notebook that someone could use to look at local wind (streamlines) at the time of a hurricane eg. the 1998 Honduras hurricane

doutriaux1 commented 6 years ago

@aashish24 @scottwittenburg @danlipsa ping

danlipsa commented 6 years ago

@doutriaux1 Not sure what is wrong here.

doutriaux1 commented 6 years ago

having a default to None

danlipsa commented 6 years ago

Oh, yes. Now I remember. Thanks!