Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
additions for data with Feature type Point
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/users/tmap/svn/repos/baker/trunk@23538 fdbf22ae-c210-0410-be80-ca943da6b8f8
  • Loading branch information
AnsleyManke committed Apr 3, 2017
1 parent 898b315 commit 7565af6
Show file tree
Hide file tree
Showing 9 changed files with 351 additions and 32 deletions.
26 changes: 15 additions & 11 deletions JavaSource/resources/ferret/scripts/LAS_setup_dsg.jnl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
! LAS_setup_dsg.jnl
4/3/2017 *acm* Additions for point data types

SAY _________________ START LAS_setup_dsg: clock seconds: ($clock_secs)

LET global_attnames = ..attnames
Expand All @@ -20,25 +22,27 @@ ENDIF
! Find the featureType attribute, and find which variables
! are marked with the cf_role and sample_dimension attributes



! Have we already found these?
IF `( ($feature_variable"0|*>1") GT 0) AND ( ($rowvar"0|*>1") GT 0)` THEN EXIT/SCRIPT

IF `IS_ELEMENT_OF_STR_N(global_attnames, "featureType") ` THEN
DEFINE SYMBOL feature_type = `..featureType`
IF ($ferret_feature_label"0|*>1") THEN DEFINE SYMBOL feature_type = ($ferret_feature_label)
DEFINE SYMBOL feature_type = `DNCASE("($feature_type)")`

REPEAT/RANGE=1:`nvars`/name=q (\
DEF SYM q = `q`;\
DEF SYM vname = `varnames[i=($q)]`;\
GO dsg_find_roles;\
IF `STRCMP("($data_($num)_var)", "($feature_variable)") EQ 0` THEN \
DEFINE SYMBOL ferret_plot_title = ($feature_variable) ID;\
IF `( ($feature_variable"0|*>1") GT 0) AND ( ($rowvar"0|*>1") GT 0)` THEN EXIT/LOOP\
)
ENDIF

! cf_role and sample_dimension are not included in DSG point datasets.

IF ($feature_type"0|point>1|*>0") THEN EXIT/SCRIPT

REPEAT/RANGE=1:`nvars`/name=q (\
DEF SYM q = `q`;\
DEF SYM vname = `varnames[i=($q)]`;\
GO dsg_find_roles;\
IF `STRCMP("($data_($num)_var)", "($feature_variable)") EQ 0` THEN \
DEFINE SYMBOL ferret_plot_title = ($feature_variable) ID;\
IF `( ($feature_variable"0|*>1") GT 0) AND ( ($rowvar"0|*>1") GT 0)` THEN EXIT/LOOP\
)

IF `($feature_variable"0|*>1") EQ 0` THEN
LET ndims = ..ndims
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@
!
! Set a couple of variables and call the script that does the work.

! Set the gif filename, changing it from .gif to the name from this request
! Set up to write info to the debug log so that FshowGO can be used
GO LAS_initial_setup
! If it a database request,

IF ($database_access_0_longitude"0|1|*>1) THEN
DEFINE SYMBOL data_0_x_var = ($database_access_0_longitude)
DEFINE SYMBOL data_0_x_var = ($database_access_0_longitude)
ELSE
DEFINE SYMBOL data_0_x_var = ($tabledap_access_0_longitude)
DEFINE SYMBOL data_0_x_var = ($tabledap_access_0_longitude)
ENDIF

IF ($database_access_0_latitude"0|1|*>1) THEN
DEFINE SYMBOL data_0_y_var = ($database_access_0_latitude)
DEFINE SYMBOL data_0_y_var = ($database_access_0_latitude)
ELSE
DEFINE SYMBOL data_0_y_var = ($tabledap_access_0_latitude)
DEFINE SYMBOL data_0_y_var = ($tabledap_access_0_latitude)
ENDIF

!go xy_insitu_poly

! Draw with a ribbon plot instead
go xy_insitu_plot
! Draw using a ribbon plot
go Plot_points_xy
269 changes: 269 additions & 0 deletions JavaSource/resources/ferret/scripts/Plot_points_xy.jnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! $Header$
! Points_xy.jnl
!
! Creates a 2D plot with a blank 'basemap' and an overlay of points
! colored by the ($ferret_plot_var) defined in LAS_initialize_data_insitu.
! Reads dsg files with the "point" feature type
! 3/31/2017 ACM

IF `($ferret_memory"25.6") LT 200` THEN SET MEM/SIZ=200

DEFINE SYMBOL start_clock_seconds = ($clock_secs)


! Set the gif filename, changing it from .gif to the name from this request
! Set up to write info to the debug log so that FshowGO can be used
GO LAS_initial_setup

! Initialize the region and data.

DEFINE SYMBOL data_initialization_script = feature_initialize_data_insitu

! DEFINE SYMBOL ferret_label = 0

SET MODE verify:always ! allows for debugging

DEFINE SYMBOL its_insitu = 1
DEFINE SYMBOL its_trajectory_map = 1
GO LAS_initialize_region 0

IF ($data_0_var"0|vid>1|*>0") THEN
DEFINE SYMBOL ferret_by_id = 1
USE "($data_0_url)"
LET varnames = ..varnames

DEFINE SYMBOL data_0_var = `varnames[i=1]`
CANCEL DATA "($data_0_url)"
ENDIF
DEFINE SYMBOL data_name_in = ($data_0_var)

GO LAS_initialize_data 0

! Check for errors (They often occur during dataset initialization.)

IF ($error_status"0|*>1") THEN
MESSAGE/ERROR **ERROR ($error_string)
EXIT/PROGRAM
ENDIF

! Set the URL label for the first dataset.
GO LAS_url_label 0

! For the annotations
IF `($ngood_data"-10|*>1") LT 0` THEN DEFINE SYMBOL ngood_data = `($data_var)[i=@NGD]`
IF `($nbad_data"-10|*>1") LT 0` THEN DEFINE SYMBOL nbad_data = `($data_var)[i=@NBD]`

IF `STRINDEX("($ferret_view"0")", "x") EQ 0` THEN

MESSAGE/ERROR **ERROR Expecting a view in xy or xyt
EXIT/PROGRAM
ENDIF

LET/UNITS=degrees_east x_var_data = ($data_x_var)
IF `($nodata"0|*>1") EQ 0` THEN
STAT x_var_data
ELSE
DEFINE SYMBOL stat_min ($region_x_lo)
ENDIF

IF ($data_y_var"0|*>1") THEN LET/UNITS=degrees_north y_var_data = ($data_y_var)
IF ($data_z_var"0|*>1") THEN LET z_var_data = ($data_z_var)
IF ($data_t_var"0|*>1") THEN LET t_var_data = ($data_t_var)

! Check for non-numeric data types. If cannot plot, just show the locations.
LET var_data = ($data_var)

DEFINE SYMBOL var_data = ($data_var)[i=1,m=1]
DEFINE SYMBOL vtype = 0
LET gettype= ($var_data)
DEFINE SYMBOL vtype = `gettype,RETURN=dtype`
DEFINE SYMBOL is_string = ($vtype"0|CHAR>1|*>0")

IF `($is_string) AND ($ferret_strfloat"0|*>1")` THEN
SET VAR/NAME = var_data_0 var_data
LET var_data = STRFLOAT(var_data_0)
SET ATT/LIKE=var_data_0 var_data
DEFINE SYMBOL ferret_plot_var var_data
ELIF ($is_string) THEN
LET var_data = 0*x_var_data
DEFINE SYMBOL note_num = `($note_num"0") + 1`
DEFINE SYMBOL note_($note_num)_lab = ($data_0_title) is not numeric. Plotting the point locations only.
CANCEL SYMBOL ferret_plot_var
ENDIF

! Special color-by-time key
IF ($ferret_plot_key"0|date_key>1|*>0") THEN

! In this case we set up a time axis, and label the color key with dates
! If the units are seconds since, we don't need that much resolution for this. Make it hours.

LET tmin = ($data_var)[i=@MIN]
LET tmax = ($data_var)[i=@MAX]

LET since_loc = STRINDEX("`($data_t_var).units`","since") - 2
IF `since_loc GT 1` THEN
LET tunits = SUBSTRING("`($data_t_var).units`",1,`since_loc`)
DEFINE SYMBOL tunits = `tunits`
ENDIF
DEFINE AXIS/T=`tmin`:`tmax`:1/T0="`($data_t_var).time_origin`"/units=($tunits) time_axis
IF ($tunits"0|seconds>1|*>0") THEN \
DEFINE AXIS/T=`tmin`:`tmax`:3600/T0="`($data_t_var).time_origin`"/units=($tunits) time_axis
DEFINE SYMBOL datekey = 1

DEFINE SYMBOL ferret_key_annotate = 0

LET ttvar = t[gt=time_axis]
DEFINE SYMBOL datekey_time_arg = ttvar

IF `($ferret_plot_levels"0|*>1") EQ 0` THEN DEFINE SYMBOL ferret_plot_levels = 50
IF `($ferret_fill_levels"0|*>1") EQ 0` THEN DEFINE SYMBOL ferret_fill_levels = ($ferret_plot_levels)

ENDIF

! Set color levels
GO LAS_initialize_var_levels

! Color key for the variable values.
! If there is no plot variable defined (only plotting locations),
! do not plot the key.

IF ($ferret_plot_key"1|0|*>1") THEN
IF `($ferret_plot_key"0|0|1>0|*>1") EQ 0` THEN DEFINE SYMBOL ferret_plot_key = ($ferret_plot_var"0|*>1")
ENDIF

! Plot qualifiers (graticule lines etc)
GO LAS_set_plot_qualifiers
IF `STRINDEX("($qualifiers)", "KEY") EQ 0 AND ($ferret_plot_key"0|*>1")` THEN DEFINE SYMBOL qualifiers = ($qualifiers)/KEY

! Open the window
GO LAS_open_window

SAY _________________ Before land underlay clock seconds: ($clock_secs)

LET pre_plot = ($clock_secs)

! Create the blank plot with bathymetries,
! coastlines, EEZ's, etc.
! Make the gray ocean lighter. To make it lighter still,
! start the colors with -40000. A lighter map needs darker graticule lines.

! In trajectory_ui.xml is an option "Bathymetry style". Choose a white
! background or the default grayscale bathymetry.

DEFINE SYMBOL basemap_palette = grayscale

DEFINE SYMBOL basemap_levels = (-inf)(-20000,-1000,500)(-1000,0,100)

IF ($ferret_bathymetry_style"1|grayscale>1|*>0") THEN
PPL COLOR,7,55,55,55 ! gray
ENDIF

IF ($ferret_bathymetry_style"0|white>1|*>0") THEN DEFINE SYMBOL basemap_palette = white
IF ($ferret_bathymetry_style"0|blue>1|*>0") THEN
DEFINE SYMBOL basemap_palette = osmc_bluescale
DEFINE SYMBOL basemap_levels = (-20000)(-10000,0,10000)
ENDIF

GO LAS_XY_overlay_basemap

PPL SHASET PROTECT

! Note LAS_fland.jnl determines the resoultion from the region symbols.
! GO LAS_fland black
! GO LAS_fland navy
! GO LAS_fland brown_dark
! GO LAS_fland green_pine

GO LAS_fland ($ferret_land_palette"gray_dark")

PPL SHASET PROTECT
SAY _________________ After land underlay clock seconds: ($clock_secs)
SAY _________________ total time for land underlay, seconds ----- `($clock_secs) - pre_plot`

! Turn on annotate_key, which persists until turned off
! (unless key_annoatate property tells us otherwise).

IF ($ferret_key_annotate"1|0|1|*>1") THEN
KEYMARK 1
ELSE
KEYMARK 0
ENDIF

! Define plot qualifiers for color ribbon plot
DEFINE SYMBOL qualifiers = ($qualifiers)/OVER/NOLAB


! Add an annotation with number of points shown
GO feature_labels

! Ribbon plot

DEFINE SYMBOL plot_command = PLOT/VS/RIBBON
DEFINE SYMBOL qualifiers = ($qualifiers)/SYM=19/siz=0.18/THICK=1

! Set the palette
! If there is no variable, only locations, and if a palette is not
! defined by ferret_palette, use black.

IF ($ferret_plot_var"0|*>1") THEN
DEFINE SYMBOL qualifiers = ($qualifiers)/PALETTE=($ferret_palette"rainbow|default>rainbow|*>*")
ELSE
DEFINE SYMBOL qualifiers = ($qualifiers)/PALETTE=($ferret_palette"black|default>black|*>*")/NOKEY
ENDIF

SAY _________________ Start line plot: clock seconds: ($clock_secs)
LET pre_plot = ($clock_secs)

! Draw the ribbon plot

DEFINE SYMBOL plot_plot_vars = x_var_data, y_var_data, var_data
($plot_command)($qualifiers)/SET ($plot_plot_vars)
IF ($ferret_annotations%0|*>1%) THEN GO key_at_top
PPL RIBBON/OVER

SAY _________________ END line plot: clock seconds: ($clock_secs)
SAY _________________ total time for line plot, seconds ----- `($clock_secs) - pre_plot`

IF ($ferret_plot_var"0|*>1") THEN
LET data_range = minmax(var_data)
DEFINE SYMBOL data_plotted_min = `data_range[i=1],prec=7`
DEFINE SYMBOL data_plotted_max = `data_range[i=2],prec=7`
ENDIF

! Add annotations

IF `($nmask_labels"0|*>1") EQ 0` THEN DEFINE SYMBOL nmask_labels = 1

REPEAT/RANGE=1:`($nmask_labels)`:1/NAME=m (\
DEFINE SYMBOL mmask = `m`;\
IF ($mask_title_($mmask)"0|*>1) THEN ; \
DEFINE SYMBOL note_num = `($note_num"0") + 1`; \
DEFINE SYMBOL note_($note_num)_lab = ($mask_title_($mmask)); \
ENDIF)

! if constraints are shown via constraint_0_lhs etc, define labels for those
GO set_constraint_labels

! restore key-annotation setting: keys not annotated
KEYMARK 0

! Save the results

GO LAS_results box

! End of file ------------Points_xy.jnl--------------------------

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SAY _________________ exiting Points_xy.jnl product script:

SAY _________________ Product script total execution time, seconds: ----- `($clock_secs) - ($start_clock_seconds)`
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! NOTE Can get just the timing info from a log of this product with
! grep seconds log.out | grep -v "SAY " | grep -v MESSAGE | grep -v independent
!
! Or just the totals for decimating, plotting and the whole script with
! grep seconds log.out | grep -v "SAY " | grep -v MESSAGE | grep -v independent | grep total
15 changes: 11 additions & 4 deletions JavaSource/resources/ferret/scripts/dsg_find_roles.jnl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
! DSG_find_roles.jnl
! Find the Profile or Trajectory dimension and get its size
! Find the Obs dimension and get its size

! 4/3/2017 *acm* Additions for point data types
! 4/3/2017 *acm* Handle datasets where dimensions are not also coordinate variables

LET var_attnames = ($vname).attnames

IF `IS_ELEMENT_OF_STR(var_attnames, "cf_role")` THEN
LET featureSize = `($vname),RETURN=msize`
DEFINE SYMBOL feature_variable = ($vname)
Expand All @@ -22,12 +24,17 @@ ENDIF
! We probably want to concoct names based on the location and time.
! Write a function to return the list for best flexibility.

IF `($feature_variable"0|*>1")` THEN
LET feature_name = ($feature_variable)

! Use ..coordnames for coordinate-variable namesinstead of ..dimnames.
! Some files have dimensions that are not coordinate variables.


IF `($feature_variable"0|*>1")` THEN
LET feature_name = ($feature_variable)
LET cnames = ..coordnames

IF `STRINDEX("($feature_variable)", "(") GT 0` THEN
DEF SYM dname = `dimnames[i=($q)]`
DEF SYM dname = `cnames[i=($q)]`

IF `($data_lon_var"0|*>1") + ($data_lat_var"0|*>1") + ($data_time_var"0|*>1") LT 3` THEN
MESSAGE/ERROR **ERROR Did not find longitude, latitude and time variables in the dataset
Expand Down
Loading

0 comments on commit 7565af6

Please sign in to comment.