Module: NumRu::GGraph
- Defined in:
- lib/numru/ggraph.rb,
lib/numru/ganalysis/histogram.rb,
lib/numru/ggraph_on_merdional_section.rb
Constant Summary collapse
- TONE_TONF_THRES_LEN =
thresfold to swith uetonf and uetone under the auto=true option in the tone method
100- TONE_TONF_THRES_SIZE =
thresfold of length of each dimension
20000- @@nannot =
thresfold of total size
0- @@startup_options =
Misc::KeywordOptAutoHelp.new( ['iws', 1, 'DCL sgpack param: Workstation ID (1:display, 2:file if DCL ver>=6)'], ['ifl', nil, 'DCL swpack param (for DCL ver.>=6): file format num for iws==2 (1:png,2:eps,3:svg,4:pdf); DCL\'s default is 4'], ['colormap', nil, 'DCL color map number (Integer); DCL\'s default is 1'], ['iwidth', nil, 'DCL swpack param (Integer): display width (pixcels)'], ['iheight', nil, 'DCL swpack param (Integer): display height (pixcels)'], ['lwait', true, 'DCL swpack param (true/false): wait mouse click to show next page'], ['lalt', false, 'DCL swpack param (false/true): true --> draw on the background'], ['isub', 96, 'DCL sgpack param (Integer): control character of subscription 96=>"`"; 95=>"_". Note that DCL\'s default is 95.'], ['lfull',false, 'DCL sgpack param (false/true)'], ['lmiss', true, 'DCL glpack param (true/false): whether to do missing value processing. Note that DCL\'s default is false.'] )
- @@fig =
Misc::KeywordOptAutoHelp.new( ['new_frame',true, 'whether to define a new frame by DCL.grfrm (otherwise, DCL.grfig is called)'], ['no_new_fig',false, 'If true, neither DCL.grfrm nor DCL.grfig is called (overrides new_frame) -- Then, you need to call one of them in advance. Convenient to set DCL parameters that are reset by grfrm or grfig.'], ['itr', 1, 'coordinate transformation number'], ['viewport',[0.2,0.8,0.2,0.8], '[vxmin, vxmax, vymin, vymax]'], ['eqdistvpt',false, 'modify viewport to equidistant for x and y (only for itr=1--4)'], ['window', nil, '(for itr<10,>50) [uxmin, uxmax, uymin, uymax]. each element allowd nil (only for itr<5,>50)'], ['xreverse','positive:down,units:hPa', '(for itr<10,>50) Assign max value to UXMIN and min value to UXMAX if condition is satisfied (nil:never, true:always, String: when an attibute has the value specified ("key:value,key:value,..")'], ['yreverse','positive:down,units:hPa', '(for itr<10,>50) Assign max value to UYMIN and min value to UYMAX if condition is satisfied (nil:never, true:always, String: when an attibute has the value specified ("key:value,key:value,..")'], ['round0', false, 'expand window range to good numbers (effective only to internal window settings)'], ['round1', false, 'expand window range to good numbers (effective even when "window" is explicitly specified)'], # for 5<=itr<=7 (Rectangular Curvilinear Coordinates) ['similar', nil, '3-element float array for similar transformation in a rectangular curvilinear coordinate, which is fed in DCL:grssim:[simfac,vxoff,vyoff], where simfac and [vxoff,vyoff] represent scaling factor and origin shift, respectively.'], # for 10<=itr<=50 (map projection): ['map_axis', nil, '(for all map projections) 3-element float array to be fed in DCL::umscnt: [uxc, uxy, rot], where [uxc, uyc] represents the tangential point (or the pole at top side for cylindrical projections), and rot represents the rotation angle. If nil, internally determined. (units: degrees)'], ['map_radius', nil, '(for itr>=20: conical/azimuhal map projections) raidus around the tangential point. (units: degrees)'], ['map_fit',nil,'(Only for itr=10(cylindrical) and 11 (Mercator)) true: fit the plot to the data window (overrides map_window and map_axis); false: do not fit (then map_window and map_axis are used); nil: true if itr==10, false if itr==11'], ['map_rsat',nil,'(Only for itr=30) satellite distance from the earth\'s center (Parameter "RSAT" for sgpack)'], ['map_window', [-180,180,-75,75], '(for itr<20: cylindrical map projections) lon-lat window [lon_min, lon_max, lat_min, lat_max ] to draw the map (units: degrees)'], ['keep_axis_offset', false, 'keep offset of titles/labels from each axis (ROFFzs in UZPACK, effective only when new_frame is false)'] )
- @@next_fig =
nil- @@axes =
Misc::KeywordOptAutoHelp.new( ['xside', 'tb', 'Where to draw xaxes (combination of t, b and u)'], ['yside', 'lr', 'Where to draw yaxes (combination of l, r and u)'], ['xtitle', nil, 'Title of x axis (if nil, internally determined)'], ['ytitle', nil, 'Title of y axis (if nil, internally determined)'], ['title', nil, 'Title of the figure'], ['xunits', nil, 'Units of x axis (if nil, internally determined)'], ['yunits', nil, 'Units of y axis (if nil, internally determined)'], ['format_units', true, 'Format unit expressions for DCL, e.g. m.s-1 -> m s\^{-1}'], ['xtickint', nil, 'Interval of x axis tickmark (if nil, internally determined)'], ['ytickint', nil, 'Interval of y axis tickmark (if nil, internally determined)'], ['xlabelint', nil, 'Interval of x axis label (if nil, internally determined)'], ['ylabelint', nil, 'Interval of y axis label (if nil, internally determined)'], ['xloglabelall', false, 'Show lavels for all log-level tick marks (x-axes) (e.g.,1000,900,800,... inseatd of 1000,500,200,...)'], ['yloglabelall', false, 'Show lavels for all log-level tick marks (y-axes) (e.g.,1000,900,800,... inseatd of 1000,500,200,...)'], ['xmaplabel', nil, 'If "lon"("lat"), use DCLExt::lon_ax(DCLExt::lat_ax) to draw xaxes; otherwise, DCL::usxaxs is used.'], ['ymaplabel', nil, 'If "lon"("lat"), use DCLExt::lon_ax(DCLExt::lat_ax) to draw yaxes; otherwise, DCL::usyaxs is used.'], ['time_ax', nil, 'Type of calendar-type time axis: nil (=> auto slection), false (do not use the time axis even if the units of the axis is a time one with since field), "h" (=> like nil, but always use the hour-resolving datetime_ax method in dclext_datetime_ax.rb), or "ymd" (=> like "h" but for y-m-d type using DCL.uc[xy]acl)'] )
- @@next_axes =
nil- @@map =
Misc::KeywordOptAutoHelp.new( ['lim', true, 'draw map lim (t or f)'], ['grid', true, 'draw map grid (t or f)'], ['vpt_boundary', false, 'draw viewport boundaries (f, t or 1,2,3.., representing the line width)'], ['wwd_boundary', false, 'draw worksation window boundaries (f, t or 1,2,3.., representing the line width)'], ['fill', false, 'fill the map if coast_world or coast_japan is true (t or f)'], ['coast_world', false, 'draw world coast lines (t or f)'], ['border_world', false, 'draw nation borders (t or f)'], ['plate_world', false, 'draw plate boundaries (t or f)'], ['state_usa', false, 'draw state boundaries of US (t or f)'], ['coast_japan', false, 'draw japanese coast lines (t or f)'], ['pref_japan', false, 'draw japanese prefecture boundaries (t or f)'], ['dgridmj', nil, 'the interval between the major lines of latitudes and longitudes. If nil, internally determined. (units: degrees) (this is a UMPACK parameter, which is nullified when uminit or grfrm is called)'], ['dgridmn', nil, 'the interval between the minor lines of latitudes and longitudes. If nil, internally determined. (units: degrees) (this is a UMPACK parameter, which is nullified when uminit or grfrm is called)'] )
- @@next_map =
nil- @@data_prep_options =
Misc::KeywordOptAutoHelp.new( ['exchange', false, 'whether to exchange x and y axes'], ['transpose', false, 'if true, exchange x and y axes'], ['xintv', 1, 'interval of data sampling in x'], ['yintv', 1, 'interval of data sampling in y'], ['xcoord', nil, 'Name of the coordinate variable for x-axis'], ['ycoord', nil, 'Name of the coordinate variable for y-axis'], ['slice', nil, 'An Array to be pathed to the GPhys#[] method to subset the data before plotting (order applied: slice -> cut -> mean)'], ['cut', nil, 'An Array or Hash to be pathed to the GPhys#cut method to subset the data before plotting (order applied: slice -> cut -> mean)'], ['mean', nil, 'An Array to be pathed to the GPhys#mean method to take mean of the data before plotting (order applied: slice -> cut -> mean)'] )
- @@line_options =
Misc::KeywordOptAutoHelp.new( ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['index', 1, 'line/mark index'], ['type', 1, 'line type'], ['label', nil, 'if a String is given, it is shown as the label'], ['max', nil, 'maximam data value'], ['min', nil, 'minimam data value'], ['legend', nil, 'legend to annotate the line type and index. nil (defalut -- do not show); a String as the legend; true to use the name of the GPhys as the legend'], ['legend_vx', nil, '(effective if legend) viewport x values of the lhs of the legend line (positive float); or nil for automatic settting (shown to the right of vpt); or move it to the left relatively (negtive float)'], ['legend_dx', nil, '(effective if legend) length of the legend line'], ['legend_vy', nil, '(effective if legend) viewport y value of the legend (Float; or nil for automatic settting)'], ['legend_size', nil, '(effective if legend) character size of the legend'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['step_plot', false, 'If true, draw stair step plot (piecewise constant line plot).'], # ['step_extend_ends', false, 'If true, extend both ends of stair step plot.'], # NOT YET IMPLEMENTED ['step_position', 0, 'Data point will be at the right corner of each step if negative, center if 0, and left corner if positive.'], ['proc_before_ax', nil, 'Proc (with no argument) to be called just before drawing the axes.'], @@data_prep_options )
- @@next_line =
nil- @@mark_options =
Misc::KeywordOptAutoHelp.new( ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['index', 1, 'mark index'], ['type', 2, 'mark type'], ['size', 0.01, 'marks size'], ['max', nil, 'maximam data value'], ['min', nil, 'minimam data value'], ['legend', nil, 'legend to annotate the mark type, index, and size. nil (defalut -- do not to show); a String as the legend; true to use the name of the GPhys as the legend'], ['legend_vx', nil, '(effective if legend) viewport x values of the lhs of the legend line (positive float); or nil for automatic settting (shown to the right of vpt); or move it to the left relatively (negtive float)'], ['legend_vy', nil, '(effective if legend) viewport y value of the legend (Float; or nil for automatic settting)'], ['legend_size', nil, '(effective if legend) character size of the legend'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['proc_before_ax', nil, 'Proc (with no argument) to be called just before drawing the axes.'], @@data_prep_options )
- @@next_mark =
nil- @@linear_contour_options =
Misc::KeywordOptAutoHelp.new( ['min', nil, 'minimum contour level'], ['max', nil, 'maximum contour level'], ['nlev', nil, 'number of levels'], ['interval', nil, 'contour interval'], ['nozero', nil, 'delete zero contour'], ['coloring', false, 'set color contours with ud_coloring'], ['clr_min', nil, '(if coloring) minimum color number for the minimum data values (nil -> uepack parameter icolor1)'], ['clr_max', nil, '(if coloring) maximum color number for the maximum data values (nil -> uepack parameter icolor2)'] )
- @@next_linear_contour_options =
nil- @@contour_levels =
Misc::KeywordOptAutoHelp.new( ['log', nil, 'approximately log-scaled levels (by using DCLExt::quasi_log_levels)'], ['log_cycle', 3, '(if log) number of levels in one-order (1 or 2 or 3)'], ['levels', nil, 'contour levels (Array/NArray of Numeric)'], ['index', nil, '(if levels) line index(es) (Array/NArray of integers, Integer, or nil)'], ['line_type',nil, '(if levels) line type(s) (Array/NArray of integers, Integer, or nil)'], ['label', nil, '(if levels) contour label(s) (Array/NArray of String, String, true, false, nil). nil is recommended.'], ['label_height',nil,'(if levels) label height(s) (Array/NArray of Numeric, Numeric, or nil). nil is recommended.'] )
- @@set_contour_levels =
false- @@next_contour =
nil- @@contour_options =
Misc::KeywordOptAutoHelp.new( ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['keep', false, 'Use the contour levels used previously'], ['proc_before_ax', nil, 'Proc (with no argument) to be called just before drawing the axes.'], @@linear_contour_options, @@contour_levels, @@data_prep_options )
- @@linear_tone_options =
Misc::KeywordOptAutoHelp.new( ['min', nil, 'minimum tone level'], ['max', nil, 'maximum tone level'], ['nlev', nil, 'number of levels'], ['interval', nil, 'tone-level interval'], ['inf_max', nil, 'if true, set the maximum tone level to infty'], ['inf_min', nil, 'if true, set the minimum tone level to infty'], ['lbound', nil, 'Same as UEPACK param LBOUND, but here it is set independently, since the author thinks that its default is better off being false/nil unlike in DCL'] )
- @@next_linear_tone_options =
nil- @@tone_levels =
Misc::KeywordOptAutoHelp.new( ['log', nil, 'approximately log-scaled levels (by using DCLExt::quasi_log_levels)'], ['log_cycle', 3, '(if log) number of levels in one-order (1 or 2 or 3)'], ['levels', nil, 'tone levels (Array/NArray of Numeric). Works together with patterns'], ['patterns', nil, 'tone patters (Array/NArray of Numeric). Works together with levels'] )
- @@set_tone_levels =
false- @@fullcolor_tone_options =
Misc::KeywordOptAutoHelp.new( ['rgb', nil, '[effective when "fullcolor" is given true] (Array/NArray) Specifies the color mapping. Example: [ DCL.isgrgb(0,0,0), DCL.isgrgb(255,255,255) ] for gray scale'], ['place_rgb', nil, '[effective when "fullcolor" is given true] (Array/NArray having the same length as the "rgb" value) Additional information needed only when you want to make the RGB map spaced unequally. Will be normalized, so the range does not matter. Example: "rgb"=>[ DCL.isgrgb(0,0,0), DCL.isgrgb(50,50,150), DCL.isgrgb(255,255,255) ], "place_rgb"=>[0,2,3] to set the intervals 2:1 among the 3 RGB values'] )
- @@next_tone =
nil- @@tone_options =
Misc::KeywordOptAutoHelp.new( ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['ltone', true, 'Same as uepack parameter ltone'], ['auto', true, 'Swith DCL.uetone and DCL.uetonf depending on the data size'], ['tonf', false, 'Use DCL.uetonf instead of DCL.uetone'], ['tonb', false, 'Use DCL.uetonb instead of DCL.uetone'], ['tonc', false, 'Use DCL.uetonc instead of DCL.uetone'], ['fullcolor', false, 'Use DCL.uipdat instead of DCL.uetone'], ['clr_min', nil, 'if an integer (in 10..99) is specified, used as the color number for the minimum data values. (the same can be done by setting the uepack parameter "icolor1")'], ['clr_max', nil, 'if an integer (in 10..99) is specified, used as the color number for the maximum data values. (the same can be done by setting the uepack parameter "icolor2")'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['keep', false, 'Use the tone levels and patterns used previously'], ['color_bar', false, 'Add a color bar: THIS IS ONLY FOR QUICK LOOK. Use the GGraph::color_bar method explicitly for full option control'], ['cbunits', nil, '[nil or true or String] if non nil, shows units in color_bar using the specified string or, when true, the units of the argument'], ['proc_before_ax', nil, 'Proc (with no argument) to be called just before drawing the axes.'], ['proc_before_tone', nil, 'Proc (with no argument) to be called just before plotting tone.'], @@linear_tone_options, @@tone_levels, @@fullcolor_tone_options, @@data_prep_options )
- @@used_fullcolor_tone =
nil- @@scatter_options =
< scatter diagram >
Misc::KeywordOptAutoHelp.new( ['title', "", 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['index', 1, 'mark index'], ['type', 2, 'mark type'], ['size', 0.01, 'marks size'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['correlation', false, 'calculate Pearson\'s correlation coefficient and show it on the bottom margin'], ['proc_before_ax', nil, 'Proc (with no argument) to be called just before drawing the axes.'], @@data_prep_options )
- @@next_scatter =
nil- @@color_scatter_options =
< scatter diagram colored by values >
Misc::KeywordOptAutoHelp.new( ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['index', 3, 'mark index (1-9)'], ['type', 10, 'mark type'], ['size', 0.01, 'marks size'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['clr_min', nil, 'if an integer (in 10..99) is specified, used as the color number for the minimum data values. (the same can be done by setting the uepack parameter "icolor1")'], ['clr_max', nil, 'if an integer (in 10..99) is specified, used as the color number for the maximum data values. (the same can be done by setting the uepack parameter "icolor2")'], ['keep', false, 'Use the tone levels and patterns used previously'], ['correlation', false, 'calculate Pearson\'s correlation coefficient and show it on the bottom margin'], @@linear_tone_options, @@tone_levels, @@data_prep_options )
- @@next_color_scatter =
nil- @@add_mode_vectors_options =
Misc::KeywordOptAutoHelp.new( ['lineindex', 1, 'line index'], ['linetype', 1, 'line type'], ['fact', 2, 'scaling factor (line length = stddev * fact for each side)'], ['style', 'line', 'style of displaying modes (line, arrow, ellipse)'] )
- @@vxfxratio =
for flow_vect
nil- @@vyfyratio =
for flow_vect
nil- @@vfratio =
for flow_vect_anyproj
nil- @@flenmax =
for flow_vect_anyproj
nil- @@vector_options =
Misc::KeywordOptAutoHelp.new( ['index', nil, 'Line index of vectors.'], ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'], ['flow_vect', true, 'If true, use DCLExt::flow_vect to draw vectors; otherwise, DCL::ugvect is used.'], ['flow_vect_anyproj', nil, 'Whether to use flow_vect_anyproj. If nil, up to the current projection number (when >=2); if true, always; if false, never. (precedence if higher than the flow_vect parameter)'], ['keep', false, 'Use the same vector scaling as in the previous call. -- Currently, works only when "flow_vect" is true'], ['factor', 1.0, '(Effective only if flow_vect) scaling factor to strech/reduce the arrow lengths'], ['unit_vect', false, 'Show the unit vector'], ['uvunits', false, 'units in the unit vector (false: never, true: read from the GPhys; a String: use that'], ['max_unit_vect', false, '(Effective only if flow_vect && unit_vect) If true, use the maximum arrows to scale the unit vector; otherwise, normalize in V coordinate.'], ['ux_unit', nil, '(If Numeric) length of the x direction unit vector (precedence of this option is lower than max_unit_vect)'], ['uy_unit', nil, '(If Numeric) length of the y direction unit vector (precedence of this option is lower than max_unit_vect)'], ['len_unit', nil, '(Effective only when flow_vect_anyproj is used) If Numeric, length of the the unit vector in terms of (fx,fy); if nil (defualt), the unitvecto length is set to be the maximum one'], ['flow_itr5', false, 'If true, use DclExt::flow_itr5 to draw vectors on 2-dim polar coordinate. Should be set DCL.sgstrn(5)'], ['polar_thinning', nil, '(Effective only when flow_vect_anyproj is used) If Numeric, specifies the maximum grid isotrpy, with which thinning is made near the poles (recommended value: 0.3 ~ 1)'], ['distvect_map', true, '(effective only for flow_vect_anyproj when map projection) by default (true) it is assumed that the vector (fx,fy) is based on lengths (such as wind velocities in m/s and fluxes in which wind velocities are incorporated [q*u, q*v]); set it to false if the vector is based on angles (such as the time derivatives of longitude and latitude).'], @@data_prep_options )
- @@next_vector =
nil- @@regression_line_options =
Misc::KeywordOptAutoHelp.new( ['x_given_y', false, 'If false (default), regress y for given x. If true, x given y.'], ['annot_slope', nil, 'Whether to show the slope on the right margin. nil: show when itr=1,4, do not show when itr=2,3; true: show; false: not show'], ['annot_intercept', false, '[Meaningful only when itr=1 (linear scaling plot)] if true, show the intercept on the right margin'], ['annot_cor', false, 'Whether to show correlation coefficient on the right margin.'], ['annot_r2', false, 'Whether to show squared correlation coefficient on the right margin.'], ['limit', false, 'If true, regression line is shown only over the range between max and min of the independent variable. If false, regression line is written over the whole range of the independent variable'], ['clip', true, "If true, use DCL's clipping not to show the line outside the viewport"], ['index', 1, 'line index'], ['type', 1, 'line type'] )
- @@next_regression_line =
nil- @@histogram_options =
Misc::KeywordOptAutoHelp.new( ['window', [nil,nil,nil,nil], "window bounds"], ['title', "histogram", "window title"], ['exchange', false, "exchange x and y"], ['fill', false, "fill bars"], ['fill_pattern', nil, "fill pattern"] )
Class Method Summary collapse
-
.__calendar_ax(axtype, xax, side, sunits, calendar, ttl, tickint = nil, labelint = nil) ⇒ Object
axtype: nil (–>auto), ‘h’ (to resolve hours), or ‘ymd’.
- .__good_range(x0, x1) ⇒ Object
- .__round_window(window) ⇒ Object
-
.__shorten_path(str, maxlen) ⇒ Object
private methods in the module.
- ._get_axinfo(vary) ⇒ Object
- ._scatter_display_corr(gpx, gpy, opts) ⇒ Object
- ._set_contour_levels_(opts) ⇒ Object
- ._set_tone_levels_(opts) ⇒ Object
- .add_mode_vectors(mean, modes, options = nil) ⇒ Object
- .annotate(str_ary, noff = nil) ⇒ Object
- .annotate_at(str_ary, vx, vy, charsize = nil, align = -1.0,, dvyfact = -1.5,, noff = nil) ⇒ Object
- .axes(xax = nil, yax = nil, options = nil) ⇒ Object
- .axes_or_map_and_ttl(gp, opts, xax, yax, gp2 = nil) ⇒ Object
- .clear_contour_levels ⇒ Object
- .clear_tone_levels ⇒ Object
- .close ⇒ Object
- .color_bar(*args) ⇒ Object
- .color_scatter(fx, fy, fz, newframe = true, options = nil) ⇒ Object
- .contour(gphys, newframe = true, options = nil) ⇒ Object
- .current_itr(fig_yet_to_be_called = false) ⇒ Object
- .data_prep_1D(gphys, opts, len1ok: false) ⇒ Object
- .data_prep_1D2(fx, fy, opts, len1ok: false) ⇒ Object
- .data_prep_2D(gps, newframe, opts, len1ok: false) ⇒ Object
- .data_prep_multidim(gphys, opts) ⇒ Object
- .fig(xax = nil, yax = nil, options = nil) ⇒ Object
- .gropn_1_if_not_yet ⇒ Object
- .histogram(gphys, newframe = true, options = nil) ⇒ Object (also: histogram1D)
- .itr_is?(itr, fig_yet_to_be_called = false) ⇒ Boolean
- .line(gphys, newframe = true, options = nil) ⇒ Object
- .map(options = nil) ⇒ Object
- .map_trn?(fig_yet_to_be_called = false) ⇒ Boolean
- .margin_info(program = nil, data_source = nil, char_height = nil, date = nil, xl = 0.0, xr = 0.0, yb = nil, yt = 0.0) ⇒ Object
- .mark(gphys, newframe = true, options = nil) ⇒ Object
- .name_selector(gp, limit) ⇒ Object
- .next_axes(options) ⇒ Object
- .next_color_scatter(options) ⇒ Object
- .next_contour(options) ⇒ Object
- .next_fig(options) ⇒ Object
- .next_line(options) ⇒ Object
- .next_linear_contour_options(options) ⇒ Object
- .next_linear_tone_options(options) ⇒ Object
- .next_map(options) ⇒ Object
- .next_mark(options) ⇒ Object
- .next_regression_line(options) ⇒ Object
- .next_scatter(options) ⇒ Object
- .next_tone(options) ⇒ Object
- .next_unit_vect_options(options) ⇒ Object
- .next_vector(options) ⇒ Object
- .polar_coordinate_boundaries(xax = nil, yax = nil) ⇒ Object
-
.profile(gphys, newframe = true, options = nil) ⇒ Object
———————————————————- Added at 080207 –.
- .regression_line(x, y, options = nil) ⇒ Object
- .scatter(fx, fy, newframe = true, options = nil) ⇒ Object
- .set_axes(options) ⇒ Object
-
.set_color_scatter(options) ⇒ Object
@@color_scatter_options.delete(“transpose”) # delete is yet to be supported @@color_scatter_options.delete(“exchange”) # (2010-01).
- .set_contour(options) ⇒ Object
- .set_contour_levels(options) ⇒ Object
- .set_fig(options) ⇒ Object
- .set_line(options) ⇒ Object
- .set_linear_contour_options(options) ⇒ Object
- .set_linear_tone_options(options) ⇒ Object
- .set_map(options) ⇒ Object
- .set_mark(options) ⇒ Object
- .set_regression_line(options) ⇒ Object
-
.set_scatter(options) ⇒ Object
@@scatter_options.delete(“transpose”) # delete is yet to be supported @@scatter_options.delete(“exchange”) # (2010-01).
- .set_step_plot_position(val, postype) ⇒ Object
- .set_tone(options) ⇒ Object
- .set_tone_levels(options) ⇒ Object
-
.set_unit_vect_options(options) ⇒ Object
< vector >.
- .set_vector(options) ⇒ Object
- .sim_trn? ⇒ Boolean
- .startup(options = nil) ⇒ Object
-
.timeplot(gphys, newframe = true, options = nil) ⇒ Object
timeplot 0802011 ######.
- .title(string) ⇒ Object
- .tone(gphys, newframe = true, options = nil) ⇒ Object
- .tone_and_contour(gphys, newframe = true, options = nil) ⇒ Object
- .vector(fx, fy, newframe = true, options = nil) ⇒ Object
- .vector_on_merdional_section(fx, fy, newframe = true, options = nil) ⇒ Object
Class Method Details
.__calendar_ax(axtype, xax, side, sunits, calendar, ttl, tickint = nil, labelint = nil) ⇒ Object
axtype: nil (–>auto), ‘h’ (to resolve hours), or ‘ymd’
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 |
# File 'lib/numru/ggraph.rb', line 1629 def __calendar_ax(axtype, xax, side, sunits, calendar, ttl, \ tickint=nil, labelint=nil) window = DCL.sgqwnd = DCL.sgqvpt /(.*) *since *(.*)/ =~ sunits if (!$1 or !$2) raise("Units mismatch. Requires time units that includes 'since'") end tun = Units[$1] dayun = Units['days'] if xax t0 = window[0] t1 = window[1] else t0 = window[2] t1 = window[3] end ts = [t0,t1].min time = UNumeric.new(ts,sunits) tstr = time.to_datetime(0.1,calendar) #jd0 = tstr.strftime('%Y%m%d').to_i tlen = tun.convert( t1-t0, dayun ).abs axtype ||= (tlen < 5) ? 'h' : 'ymd' reverse = t1 < t0 if axtype == 'h' dh = 0.0 else tstr0 = tstr.to_date dh = tstr - tstr0 if dh>1e-2 # << 1 な適当な小さな数 dh -= 1.0 tstr0 += 1.0 end tend0 = (tstr+tlen).to_date end if xax unless(reverse) DCL.grswnd(dh, tlen+dh, window[2], window[3] ) else DCL.grswnd(tlen+dh, dh, window[2], window[3] ) end DCL.grstrf opts = {'cside'=>side} opts['dtick1'] = tickint if tickint opts['dtick2'] = labelint if labelint if axtype == 'h' DCLExt.datetime_ax(tstr, tstr+tlen, opts ) else DCLExt.date_ax(tstr0, tend0, opts ) ## DCL.ucxacl(side,jd0,tlen) #Old: use it again if UCPACK is improved end else unless(reverse) DCL.grswnd(window[0], window[1], dh, tlen+dh) else DCL.grswnd(window[0], window[1], tlen+dh, dh) end DCL.grstrf opts = {'yax'=>true, 'cside'=>side} opts['dtick1'] = tickint if tickint opts['dtick2'] = labelint if labelint if axtype == 'h' DCLExt.datetime_ax(tstr, tstr+tlen, opts ) else DCLExt.date_ax(tstr0, tend0, opts ) ## DCL.ucyacl(side,jd0,tlen) #Old: use it again if UCPACK is improved end end DCL.grswnd(*window) DCL.grstrf end |
.__good_range(x0, x1) ⇒ Object
1571 1572 1573 1574 1575 1576 1577 1578 |
# File 'lib/numru/ggraph.rb', line 1571 def __good_range(x0,x1) x0 = x0.to_f x1 = x1.to_f xw = (x1-x0).abs e10, lx = (Math::log10(xw)).divmod(1.0) ef = 5.0 * 10**(-e10) [(x0*ef).floor/ef,(x1*ef).ceil/ef] end |
.__round_window(window) ⇒ Object
1580 1581 1582 1583 1584 |
# File 'lib/numru/ggraph.rb', line 1580 def __round_window(window) x0,x1 = __good_range(window[0],window[1]) y0,y1 = __good_range(window[2],window[3]) [ x0, x1, y0, y1 ] end |
.__shorten_path(str, maxlen) ⇒ Object
private methods in the module
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
# File 'lib/numru/ggraph.rb', line 1130 def __shorten_path(str,maxlen) return str if str.length <= maxlen astr = str.split(/\//) while(str.length > maxlen) astr.length!=2 ? at = (astr.length)/2 : at = 0 astr.delete_at( at ) (a = astr.dup)[at, 0] = '...' # insert(at,'...') if Ruby>=1.8 str = a.join('/') end str end |
._get_axinfo(vary) ⇒ Object
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 |
# File 'lib/numru/ggraph.rb', line 1808 def _get_axinfo(vary) if vary.nil? hash = { 'title'=>'', 'units'=>'' } else #raise "Not 1D" if vary.rank!=1 hash = { 'title'=>(vary.long_name || vary.name), #.gsub('_','' ) 'units'=>(vary.get_att('units') || '') #.gsub('_',' ') } end hash end |
._scatter_display_corr(gpx, gpy, opts) ⇒ Object
3125 3126 3127 3128 3129 3130 3131 |
# File 'lib/numru/ggraph.rb', line 3125 def _scatter_display_corr(gpx, gpy, opts) require "numru/ganalysis/covariance" r, n = gpx.correlation(gpy,0) r = r.val if r.is_a?(GPhys) DCL::uxsttl("B","r=#{DCL.chval('A',r)}", 0) return [r, n] end |
._set_contour_levels_(opts) ⇒ Object
2557 2558 2559 2560 2561 2562 2563 |
# File 'lib/numru/ggraph.rb', line 2557 def _set_contour_levels_(opts) raise ArgumentError, "'levels' must be explicitly set" if !opts['levels'] DCLExt.ud_set_contour(opts['levels'],opts['index'],opts['line_type'], opts['label'],opts['label_height']) @@set_contour_levels=true nil end |
._set_tone_levels_(opts) ⇒ Object
2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 |
# File 'lib/numru/ggraph.rb', line 2758 def _set_tone_levels_(opts) if !opts['levels'] && !opts['patterns'] end if opts['levels'] levels = opts['levels'] else raise ArgumentError,"'levels' must be explicitly set" end if opts['patterns'] patterns = opts['patterns'] else nlev = levels.length - 1 itpat = DCL.ueiget('itpat') iclr1 = DCL.ueiget('icolor1') iclr2 = DCL.ueiget('icolor2') patterns = (0...nlev).collect{|i| (((iclr2-iclr1)/(nlev-1.0)*i+iclr1).round) * 1000 + itpat } end DCLExt.ue_set_tone(levels,patterns) @@set_tone_levels=true nil end |
.add_mode_vectors(mean, modes, options = nil) ⇒ Object
3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 |
# File 'lib/numru/ggraph.rb', line 3140 def add_mode_vectors(mean, modes, =nil) opts = @@add_mode_vectors_options.interpret() unless modes.shape == [2,2] || modes.shape[2,1] || modes.shape == [2] raise ArgumentError, "the second arg must be a NArray of the shape [2,2], [2,1], or [2]." end unless (mean.length == 2) && (mean.is_a?(GPhys) || mean.is_a?(NArray) || mean.is_a?(Array)) raise ArgumentError, "the 1st arg must be a GPhys, NArray, or Array with length of 2" end mean = mean.val if mean.is_a?(GPhys) modes = modes.val * opts['fact'] index = opts['lineindex'] type = opts['linetype'] modes = modes.newdim(-1) if modes.rank == 1 for i in 0...(modes.shape[1]) case opts['style'] when "line" DCL::sgplzu([mean[0]-modes[0,i],mean[0]+modes[0,i]], [mean[1]-modes[1,i],mean[1]+modes[1,i]], type,index) when "arrow" DCL::sglazu(mean[0]-modes[0,i],mean[1]-modes[1,i], mean[0]+modes[0,i],mean[1]+modes[1,i], type,index) when "ellipse" raise "Drawing an ellipse needs two modes" unless modes.shape[1]==2 arg = NArray.int(361).indgen!.to_f / 180.0 * NMath::PI s = NMath.sin(arg) c = NMath.cos(arg) x = mean[0] + modes[0,0] * c + modes[0,1] * s y = mean[1] + modes[1,0] * c + modes[1,1] * s DCL::sgplzu(x,y,type,index) else raise "invalid value for the option 'style' in add_mode_vectors: #{kind}" end end end |
.annotate(str_ary, noff = nil) ⇒ Object
1237 1238 1239 1240 1241 1242 1243 1244 |
# File 'lib/numru/ggraph.rb', line 1237 def annotate(str_ary, noff=nil) charsize = 0.7 * DCL.uzpget('rsizec1') vxmin,vxmax,vymin,vymax = DCL.sgqvpt vx = vxmax + 0.01 vy = vymax - charsize/2 nannot = annotate_at(str_ary,vx,vy,charsize,-1.0,-1.5,noff) @@nannot = nannot end |
.annotate_at(str_ary, vx, vy, charsize = nil, align = -1.0,, dvyfact = -1.5,, noff = nil) ⇒ Object
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
# File 'lib/numru/ggraph.rb', line 1246 def annotate_at(str_ary,vx,vy,charsize=nil, align=-1.0, dvyfact=-1.5, noff=nil) raise TypeError,"Array expected" if ! str_ary.is_a?(Array) charsize = 0.7 * DCL.uzpget('rsizec1') unless(charsize) dvy = charsize*dvyfact vy += noff*dvy if noff str_ary.each{|str| DCL::sgtxzr(vx,vy,str,charsize,0,align,1) vy += dvy } nannot = str_ary.length nannot += noff if noff nannot end |
.axes(xax = nil, yax = nil, options = nil) ⇒ Object
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 |
# File 'lib/numru/ggraph.rb', line 1703 def axes(xax=nil, yax=nil, =nil) if @@next_axes = ( ? @@next_axes.update() : @@next_axes ) @@next_axes = nil end opts = @@axes.interpret() if itr51 = (DCL.sgqtrn == 51) wnd = DCL::sgqwnd DCL::sgswnd( *(cwd = DCL::sgqcwd) ) DCL::sgstrn(1) DCL::sgstrf end if opts['xside'].length > 0 xai = _get_axinfo(xax) if opts['xmaplabel'] == "lon" opts['xside'].split('').each{|s| # scan('.') also works DCLExt.lon_ax('cside'=>s, 'dtick1'=>opts['xtickint'], 'dtick2'=>opts['xlabelint']) } DCL.uxsttl('b', (opts['xtitle'] || xai['title']), 0.0) elsif opts['xmaplabel'] == "lat" opts['xside'].split('').each{|s| # scan('.') also works DCLExt.lat_ax('xax'=>true, 'cside'=>s, 'dtick1'=>opts['xtickint'], 'dtick2'=>opts['xlabelint']) } DCL.uxsttl('b', (opts['xtitle'] || xai['title']), 0.0) else sunits = opts['xunits'] || xai['units'] units = Units[sunits] if opts['time_ax'] != false && \ /since/ =~ sunits && units =~ Units['days since 0001-01-01'] && \ ( calendar = ( xax.get_att('calendar') || nil ) ; \ UNumeric::supported_calendar?(calendar) ) opts['xside'].split('').each do |s| # scan('.') also works ttl = opts['xtitle'] || xai['title'] __calendar_ax(opts['time_ax'], true, s, sunits, calendar, ttl, opts['xtickint'], opts['xlabelint']) end else sunits = DCLExt.format_units(sunits) if opts['format_units'] DCL.uscset('cxttl', (opts['xtitle'] || xai['title']) ) DCL.uscset('cxunit', sunits) DCL.uspset('dxt', opts['xtickint']) if(opts['xtickint']) DCL.uspset('dxl', opts['xlabelint']) if(opts['xlabelint']) if(opts['xloglabelall']) DCL.uspset('nlblx', 4) DCL.ulsxbl([1,2,3,4,5,6,7,8,9]) end opts['xside'].split('').each{|s| # scan('.') also works DCL.usxaxs(s) } end end end if opts['yside'].length > 0 yai = _get_axinfo(yax) if opts['ymaplabel'] == "lon" opts['yside'].split('').each{|s| # scan('.') also works DCLExt.lon_ax('yax'=>true, 'cside'=>s, 'dtick1'=>opts['ytickint'], 'dtick2'=>opts['ylabelint']) } DCL.uysttl('l', (opts['ytitle'] || yai['title']), 0.0) elsif opts['ymaplabel'] == "lat" opts['yside'].split('').each{|s| # scan('.') also works DCLExt.lat_ax('cside'=>s, 'dtick1'=>opts['ytickint'], 'dtick2'=>opts['ylabelint']) } DCL.uysttl('l', (opts['ytitle'] || yai['title']), 0.0) else sunits=(opts['yunits'] || yai['units']) units = Units[sunits] if opts['time_ax'] != false && \ /since/ =~ sunits && units =~ Units['days since 0001-01-01'] && \ ( calendar = ( yax.get_att('calendar') || nil ) ; \ UNumeric::supported_calendar?(calendar) ) opts['yside'].split('').each do |s| # scan('.') also works ttl = opts['ytitle'] || yai['title'] __calendar_ax(opts['time_ax'], false, s, sunits, calendar, ttl, opts['ytickint'], opts['ylabelint']) end else sunits = DCLExt.format_units(sunits) if opts['format_units'] DCL.uscset('cyttl', (opts['ytitle'] || yai['title']) ) DCL.uscset('cyunit', sunits ) DCL.uspset('dyt', opts['ytickint']) if(opts['ytickint']) DCL.uspset('dyl', opts['ylabelint']) if(opts['ylabelint']) if(opts['yloglabelall']) DCL.uspset('nlbly', 4) DCL.ulsybl([1,2,3,4,5,6,7,8,9]) end opts['yside'].split('').each{|s| # scan('.') also works DCL.usyaxs(s) if s=='l' && sunits && sunits != '' DCL.uzpset('roffxt', DCL.uzpget('rsizec1')*1.5 ) end } end end title(opts['title']) if opts['title'] end if itr51 DCL::sgstrn(51) DCL::sgswnd( *wnd ) DCL::sgscwd( *cwd ) DCL::sgstrf end nil end |
.axes_or_map_and_ttl(gp, opts, xax, yax, gp2 = nil) ⇒ Object
2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 |
# File 'lib/numru/ggraph.rb', line 2609 def axes_or_map_and_ttl(gp, opts, xax, yax, gp2=nil) if !gp2 ttl = opts['title'] || name_selector(gp, 30) else ttl = opts['title'] || '(' << name_selector(gp, 15) << ',' << name_selector(gp2, 15) << ')' end if map_trn? map if opts['map_axes'] && itr_is?(10) vpt = DCL.sgqvpt wnd = DCL.sgqwnd if wnd.include?(DCL.glrget('rundef')) map_fit = false wnd = DCL.sgqtxy cnt = DCL.umqcnt else map_fit = true end vrat = ( (vpt[3]-vpt[2]) / (vpt[1]-vpt[0]) ).abs wrat = ( (wnd[3]-wnd[2]) / (wnd[1]-wnd[0]) ).abs if wrat < vrat vyoff = (vpt[3]+vpt[2])/2 dvy2 = (vpt[1]-vpt[0])*wrat/2 vpt[2] = vyoff - dvy2 vpt[3] = vyoff + dvy2 else vxoff = (vpt[1]+vpt[0])/2 dvx2 = (vpt[3]-vpt[2])/wrat/2 vpt[0] = vxoff - dvx2 vpt[1] = vxoff + dvx2 end trn = DCL.sgqtrn if map_fit fig(xax,yax, {'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt, 'keep_axis_offset'=>true}) axes(xax, yax, 'title'=>ttl) fig(xax,yax,{'itr'=>trn, 'new_frame'=>false, 'viewport'=>vpt, 'map_fit'=>true, 'keep_axis_offset'=>true}) else xax_map = xax[0..1].copy xax_map[0] = cnt[0] + wnd[0] xax_map[1] = cnt[0] + wnd[1] yax_map = yax[0..1].copy yax_map[0] = wnd[2] yax_map[1] = wnd[3] fig(xax_map,yax_map,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt, 'keep_axis_offset'=>true}) axes(xax_map, yax_map, 'title'=>ttl) fig(xax_map,yax_map,{'itr'=>trn, 'new_frame'=>false, 'viewport'=>vpt, 'map_fit'=>false, 'map_axis'=>cnt, 'map_window'=>wnd, 'keep_axis_offset'=>true}) end else title( ttl ) end elsif itr_is?(5) polar_coordinate_boundaries(xax,yax) title( ttl ) else axes(xax, yax, 'title'=>ttl) end annotate(gp.lost_axes) if opts['annotate'] end |
.clear_contour_levels ⇒ Object
2565 2566 2567 2568 2569 |
# File 'lib/numru/ggraph.rb', line 2565 def clear_contour_levels @@set_contour_levels=false DCL.udiclv # this may not be needed nil end |
.clear_tone_levels ⇒ Object
2781 2782 2783 2784 |
# File 'lib/numru/ggraph.rb', line 2781 def clear_tone_levels @@set_tone_levels=false nil end |
.close ⇒ Object
1175 1176 1177 |
# File 'lib/numru/ggraph.rb', line 1175 def close DCL.grcls end |
.color_bar(*args) ⇒ Object
1214 1215 1216 1217 1218 1219 1220 |
# File 'lib/numru/ggraph.rb', line 1214 def (*args) if @@used_fullcolor_tone DCLExt.(*args) else DCLExt.(*args) end end |
.color_scatter(fx, fy, fz, newframe = true, options = nil) ⇒ Object
3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 |
# File 'lib/numru/ggraph.rb', line 3038 def color_scatter(fx, fy, fz, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "4th arg (newframe) must be true or false" end if @@next_color_scatter = ( ? @@next_color_scatter.update() : @@next_color_scatter ) @@next_color_scatter = nil end opts = @@color_scatter_options.interpret() # interpret cut, slice, etc gpx, closerx = data_prep_multidim(fx, opts) gpy, closery = data_prep_multidim(fy, opts) gpz, closerz = data_prep_multidim(fz, opts) # flatten gphys data ----- fakeaxis = Axis.new.set_pos(VArray.new(NArray.int(gpx.length).indgen!, {"long_name"=>"fake", "units"=>""}, "fake")) fakegrid = Grid.new(fakeaxis) gpx, gpy, gpz = [gpx, gpy, gpz].collect{|gp| na = gp.val.reshape!(gp.length) attr = gp.data.attr_copy newgp = GPhys.new(fakegrid,VArray.new(na,attr,gp.name)) newgp.set_lost_axes(gp.lost_axes) newgp } # ------------------------ xax = gpx.data yax = gpy.data if newframe fig(xax, yax) axes_or_map_and_ttl(gpz, opts, xax, yax) end zval = gpz.data.val # < levels setting --- taken from tone > if opts['clr_min'] icolor1_bak = DCL.uepget('icolor1') DCL.uepset('icolor1', opts['clr_min']) end if opts['clr_max'] icolor2_bak = DCL.uepget('icolor2') DCL.uepset('icolor2', opts['clr_max']) end rmiss = DCL.glrget('rmiss') if !opts['keep'] or DCL.ueqntl==0 if !opts['levels'] && opts['log'] levels, = DCLExt.quasi_log_levels_z(zval, opts['nlev'], opts['max'], opts['min'], opts['log_cycle']) levels.unshift(rmiss) if !opts['max'] && levels[0]<0 levels.push(rmiss) if !opts['max'] && levels[-1]>0 opts['levels'] = levels end if opts['levels'] backup = @@set_tone_levels _set_tone_levels_(opts) @@set_tone_levels = backup elsif opts['patterns'] # Here only the colors are used from patterns raise "option 'patterns' is not effective unless 'levels' is specified" elsif !@@set_tone_levels DCL.ueitlv DCLExt.ue_set_linear_levs(zval, opts) else DCL.ueitlv if !@@set_tone_levels end end DCL::uemrkz(xax.val, yax.val, zval, opts['type'], opts['index'], opts['size']) if opts['correlation'] return _scatter_display_corr(gpx, gpy, opts) else return nil end #< finish > ensure DCL.uepset('icolor1', icolor1_bak) if opts['clr_min'] DCL.uepset('icolor2', icolor2_bak) if opts['clr_max'] closerx.call if closerx closery.call if closery closerz.call if closerz end |
.contour(gphys, newframe = true, options = nil) ⇒ Object
2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 |
# File 'lib/numru/ggraph.rb', line 2668 def contour(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end if @@next_contour = ( ? @@next_contour.update() : @@next_contour ) @@next_contour = nil end if @@next_linear_contour_options = ( ? @@next_linear_contour_options.update() : @@next_linear_contour_options ) @@next_linear_contour_options = nil end opts = @@contour_options.interpret() xax, yax, closer, gp = data_prep_2D([gphys], newframe, opts) if newframe fig(xax, yax) if opts['proc_before_ax'] opts['proc_before_ax'].call end axes_or_map_and_ttl(gp,opts, xax, yax) end if !opts['keep'] or DCL.udqcln==0 if !opts['levels'] && opts['log'] levels, mjmn = DCLExt.quasi_log_levels_z(gp.data.val, opts['nlev'], opts['max'], opts['min'], opts['log_cycle']) opts['levels'] = levels opts['index'] = NArray.to_na(mjmn)*2 + 1 if !opts['index'] opts['label'] = true if opts['label'].nil? end if (opts['levels']) backup = @@set_contour_levels _set_contour_levels_(opts) @@set_contour_levels = backup elsif !@@set_contour_levels DCLExt.ud_set_linear_levs(gp.data.val, opts) end end saved_udparams = nil if DCL.udqcln >= 3 lv1, = DCL.udqclv(1) lv2, = DCL.udqclv(2) lv3, = DCL.udqclv(3) if lv2-lv1 != lv3-lv2 saved_udparams = DCLExt.ud_set_params({'lmsg'=>false}) end end DCL.uwsgxa(xax.val) if xax.rank==1 DCL.uwsgya(yax.val) if yax.rank==1 DCL.udcntz(gp.data.val) DCLExt.ud_set_params(saved_udparams) if saved_udparams closer.call if closer nil end |
.current_itr(fig_yet_to_be_called = false) ⇒ Object
1309 1310 1311 1312 1313 1314 1315 1316 |
# File 'lib/numru/ggraph.rb', line 1309 def current_itr( fig_yet_to_be_called=false ) if fig_yet_to_be_called current_itr = ( @@next_fig && @@next_fig['itr'] ) || @@fig['itr'] else current_itr = DCL.sgqtrn end current_itr end |
.data_prep_1D(gphys, opts, len1ok: false) ⇒ Object
2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 |
# File 'lib/numru/ggraph.rb', line 2006 def data_prep_1D(gphys, opts, len1ok: false) gp = gphys if gp.is_a?(String) gp = GPhys::IO.str2gphys(gp) closer = Proc.new{gp.close} else closer = nil end gp = gp[*opts['slice']] if opts['slice'] if (cut = opts['cut']) # substitution, not == if cut.is_a?(Array) gp = gp.cut(*cut) else gp = gp.cut(cut) end end gp = gp.mean(*opts['mean']) if opts['mean'] if len1ok gp = gp.first1D else gp = gp.first1Dreally end window = ( @@next_fig['window'] if @@next_fig ) || @@fig['window'] window = ( window ? window.dup : [nil, nil, nil, nil]) max = opts['max']; min = opts['min'] if !opts['exchange'] xd = gp.coord(0) yd = gp.data window[2] = min if min window[3] = max if max else yd = gp.coord(0) xd = gp.data window[0] = min if min window[1] = max if max end [xd, yd, closer, gp, window] end |
.data_prep_1D2(fx, fy, opts, len1ok: false) ⇒ Object
2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 |
# File 'lib/numru/ggraph.rb', line 2045 def data_prep_1D2(fx, fy, opts, len1ok: false) gpx = fx gpy = fy to_close = Array.new if gpx.is_a?(String) gpx = GPhys::IO.str2gphys(gpx) to_close.push(gpx) end if gpy.is_a?(String) gpy = GPhys::IO.str2gphys(gpy) to_close.push(gpy) end if to_close.length > 0 closer = Proc.new{to_close.each{|gp| gp.close}} else closer = nil end gpx = gpx[*opts['slice']] if opts['slice'] if (cut = opts['cut']) # substitution, not == if cut.is_a?(Array) gpx = gpx.cut(*cut) else gpx = gpx.cut(cut) end end gpx = gpx.mean(*opts['mean']) if opts['mean'] if len1ok gpx = gpx.first1D else gpx = gpx.first1Dreally end gpy = gpy[*opts['slice']] if opts['slice'] if (cut = opts['cut']) # substitution, not == if cut.is_a?(Array) gpy = gpy.cut(*cut) else gpy = gpy.cut(cut) end end gpy = gpy.mean(*opts['mean']) if opts['mean'] if len1ok gpy = gpy.first1D else gpy = gpy.first1Dreally end [gpx, gpy, closer] end |
.data_prep_2D(gps, newframe, opts, len1ok: false) ⇒ Object
1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 |
# File 'lib/numru/ggraph.rb', line 1926 def data_prep_2D(gps, newframe, opts, len1ok: false) opend_here = [] gps.collect!{|gp| if gp.is_a?(String) gp = GPhys::IO.str2gphys(gp) opend_here.push(gp) end gp = gp[*opts['slice']] if opts['slice'] if (cut = opts['cut']) # substitution, not == if cut.is_a?(Array) gp = gp.cut(*cut) else gp = gp.cut(cut) end end gp = gp.mean(*opts['mean']) if opts['mean'] if len1ok gp = gp.first2D else gp = gp.first2Dreally end gp = gp.transpose(1,0) if opts['transpose'] || opts['exchange'] if opts['xintv'] || opts['yintv'] gp = gp.copy sh = gp.shape if opts['xintv'] && ((xi=opts['xintv']) >= 2) idx = NArray.int((sh[0]/xi.to_f).ceil).indgen!*xi # 0,xi,2*xi,.. gp = gp[idx, true] end if opts['yintv'] && ((yi=opts['yintv']) >= 2) idx = NArray.int((sh[1]/yi.to_f).ceil).indgen!*yi # 0,yi,2*yi,.. gp = gp[true, idx] end end gp } if opend_here.length > 0 closer = Proc.new{opend_here.each{|gp| gp.data.file.close}} else closer = nil end xd = gps[0].coord(0) yd = gps[0].coord(1) if xc=opts['xcoord'] xa = gps[0].coord(xc) if xa.rank == 1 && xa.length != xd.length raise("Len of #{xc} do not agree with the #{xd.name} dim") elsif xa.rank == 2 && xa.shape != gps[0].shape raise("Invalid 2D coord shape. #{xc} : #{xa.shape.inspect}" + " vs #{gps[0].shape.inspect}") end xd = xa end if yc=opts['ycoord'] ya = gps[0].coord(yc) if ya.rank == 1 && ya.length != yd.length raise("Len of #{yc} do not agree with the #{yd.name} dim") elsif ya.rank == 2 && ya.shape != gps[0].shape raise("Invalid 2D coord shape. #{yc} : #{ya.shape.inspect}" + " vs #{gps[0].shape.inspect}") end yd = ya end if map_trn?(newframe) # // convert to the anti-clockwise coordinate in case for map filling # (Because of a bug in UMFMAP in DCL 5.3) --> if ( (xd[-1].val-xd[0].val)*(yd[-1].val-yd[0].val) < 0 ) gps.collect!{|gp| gp.copy[true,-1..0]} yd = gps[0].coord(1) end # <-- /// gps.collect!{|gp| gp.cyclic_ext(0)} #cyclic extentn along lon xd = gps[0].coord(0) elsif itr_is?(5, newframe) gps.collect!{|gp| gp.cyclic_ext_with_modulo(1, 360.0)} #cyclic ext along azimuth yd = gps[0].coord(1) end [xd, yd, closer, *gps] end |
.data_prep_multidim(gphys, opts) ⇒ Object
2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 |
# File 'lib/numru/ggraph.rb', line 2096 def data_prep_multidim(gphys, opts) gp = gphys if gp.is_a?(String) gp = GPhys::IO.str2gphys(gp) closer = Proc.new{gp.close} else closer = nil end gp = gp[*opts['slice']] if opts['slice'] if (cut = opts['cut']) # substitution, not == if cut.is_a?(Array) gp = gp.cut(*cut) else gp = gp.cut(cut) end end gp = gp.mean(*opts['mean']) if opts['mean'] [gp, closer] end |
.fig(xax = nil, yax = nil, options = nil) ⇒ Object
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 |
# File 'lib/numru/ggraph.rb', line 1322 def fig(xax=nil, yax=nil, =nil) # xax and yax are needed (i.e. Axis objects) if not map projection if @@next_fig = ( ? @@next_fig.update() : @@next_fig ) @@next_fig = nil end opts = @@fig.interpret() if opts['no_new_fig'] # do nothing elsif opts['new_frame'] DCL.grfrm else if opts['keep_axis_offset'] # SAVE OFFSET VALUES offset_org = (%w(XT XB YL YR)).map{|zs| DCL::uzpget("ROFF#{zs}")} end DCL.grfig end raise "viewport's length must be 4" if opts['viewport'].length != 4 DCL.grsvpt(*opts['viewport']) @@nannot = 0 if opts['window'] if !opts['window'].is_a?(Array) || opts['window'].length!=4 raise "Option 'window' must be an Array of length==4" end end itr = opts['itr'] DCL.grstrn(itr) map_fit = ( (itr==10 and opts['map_fit']!=false) or (itr==11 and opts['map_fit']==true) ) DCL.sgpset("RSAT",opts['map_rsat']) if (opts['map_rsat']) if ( (1<=itr and itr<=4) or (51<=itr and itr<=99) or map_fit ) window = opts['window'] window = ( window ? window.dup : [nil, nil, nil, nil]) if window.include?(nil) raise(ArgumentError, "xax and yax must be provided") if !xax or !yax if (xreverse=opts['xreverse']).is_a?(String) atts = opts['xreverse'].split(',').collect{|v| v.split(':')} xreverse = false atts.each{|key,val| xreverse = ( key.downcase=="units" ? (Units.new(xax.get_att(key)) =~ Units.new(val)) : (xax.get_att(key) == val) ) break if xreverse } end if (yreverse=opts['yreverse']).is_a?(String) atts = opts['yreverse'].split(',').collect{|v| v.split(':')} yreverse = false atts.each{|key,val| yreverse = ( key.downcase=="units" ? (Units.new(yax.get_att(key)) =~ Units.new(val)) : (yax.get_att(key) == val) ) break if yreverse } end if xreverse xrange = [ xax.max.to_f, xax.min.to_f ] else xrange = [ xax.min.to_f, xax.max.to_f ] end if yreverse yrange = [ yax.max.to_f, yax.min.to_f ] else yrange = [ yax.min.to_f, yax.max.to_f ] end [ xrange, yrange ].each do |range| r0 = range[0] r1 = range[1] if r0 == r1 if r0.nil? raise("Cannot set a window. Maybe plotting all-missing data?") end # if the max and min of the range is the same, shift them a bit range[0] = DCL.rgnlt(r0) range[1] = DCL.rgngt(r0) if range[0] == range[1] # if min and max are still the same range[0] -= 1 range[1] += 1 end end end default_window=[xrange[0], xrange[1], yrange[0], yrange[1]] default_window = __round_window(default_window) if opts['round0'] if (if [].respond_to?("nitems") window.nitems == 0 else window.none? end) # if all elements is nil window = default_window else window.each_index do |i| window[i] = default_window[i] if window[i] == nil end end window = __round_window(window) if opts['round1'] end end case itr when 1..4,51..99 # all but for map projections and curvilinear coordinates if xax.rank==2 || yax.rank==2 if xax.rank==2 nx,ny = xax.shape else nx,ny = yax.shape end if x2d = (xax.rank==2) ux = NArray.sfloat(nx).indgen! cx = xax.val else ux = xax.val cx = NArray.sfloat(nx,ny) cx[0,0] = DCL::glrget('rundef') end if y2d = (yax.rank==2) uy = NArray.sfloat(ny).indgen! cy = yax.val else uy = yax.val cy = NArray.sfloat(nx,ny) cy[0,0] = DCL::glrget('rundef') end DCL::grswnd(0.0,ux.max,0.0,uy.max) DCL::grscwd(*window) DCL::g2sctr(ux,uy,cx,cy) DCL::grstrn(51) DCL.uwsgxa(ux) DCL.uwsgya(uy) else DCL.grswnd(*window) end if itr <= 4 and opts['eqdistvpt'] # modify viewport to equidistant vx1,vx2,vy1,vy2 = opts['viewport'] wx1,wx2,wy1,wy2 = window vxw = (vx2-vx1).abs vyw = (vy2-vy1).abs wxw = (wx2-wx1).abs wyw = (wy2-wy1).abs if ( [vxw,vyw,wxw,wyw].min > 0 ) rx = wxw / vxw ry = wyw / vyw if rx > ry rc = ry/rx vym = (vy1+vy2)/2.0 vy1 = vym - rc*vyw/2.0 vy2 = vym + rc*vyw/2.0 elsif rx < ry rc = rx/ry vxm = (vx1+vx2)/2.0 vx1 = vxm - rc*vxw/2.0 vx2 = vxm + rc*vxw/2.0 end DCL.grsvpt(vx1,vx2,vy1,vy2) end end when 5,6 if opts['similar'] similar=opts['similar'] DCL.grssim(*similar) elsif opts['window'] if defined?(DCL::DCLVERSION) && DCL::DCLVERSION >= '5.3' DCL.sgscwd(*opts['window']) else raise "You need DCL 5.3 or later to use the 'window' parameter in this transform (#{itr}). Use 'similar' instead." end else case itr when 5 vxmin,vxmax,vymin,vymax=DCL.sgqvpt raise(ArgumentError, "xax must be provided") if !xax simfac = (vymax-vymin)/(xax.max*2) # only xax is used similar = [simfac,0.0,0.0] DCL.grssim(*similar) else raise NotImplementedError, "Sorry, automatic window setting is yet to be available for the transform #{itr}. Please specify the 'similar' or 'window' parameter" end end when 10..19 sv = DCL.umpget('lglobe') if !map_fit map_axis = opts['map_axis'] || [180.0, 0.0, 0.0] DCL::umscnt( *map_axis ) map_window = opts['map_window'] raise "map_window's length must be 4" if map_window.length != 4 map_lat_range = [ map_window[2], map_window[3] ] if map_lat_range.is_a?(Range) map_lat_range = [map_lat_range.first, map_lat_range.end] end case ( map_axis[2] - map_axis[1] ) % 360 when 0 tyrange = map_lat_range when 180 tyrange = [ -map_lat_range[1], -map_lat_range[0] ] else tyrange = [ -75, 75 ] # latange is ignored end DCL::grstxy(map_window[0], map_window[1], tyrange[0], tyrange[1]) # 'lglobe' becomes true when itr >= 12 or data coverage is almost global for Mercator DCL.umpset('lglobe', (itr >= 12) || ((itr == 11) && (tyrange[0].abs >= 75) && (tyrange[1].abs >= 75) && (tyrange[0] * tyrange[1] < 0))) else lon_cent =( window[0] + window[1] ) / 2.0 dlon2 = ( window[1] - window[0] ) / 2.0 map_axis = [ lon_cent, 0.0, 0.0 ] DCL::sgswnd(*window) DCL::umscnt( *map_axis ) DCL::grstxy( -dlon2, dlon2, window[2], window[3] ) # 'lglobe' becomes true when data coverage is almost global for Mercator DCL.umpset('lglobe', (itr == 11) && (window[2].abs >= 75) && (window[3].abs >= 75) && (window[2] * window[3] < 0)) end DCL::umpfit when 20..34 map_axis = opts['map_axis'] || [180.0, 90.0, 0.0] map_radius = opts['map_radius'] || 70.0 DCL::umscnt( *map_axis ) case itr when 31 v = opts['viewport'] vptsize = [ v[1]-v[0], v[3]-v[2] ].min DCL::grssim( vptsize*0.25/Math::tan(0.5*Math::PI*map_radius/180.0), 0.0, 0.0 ) when 22 v = opts['viewport'] vptsize = [ v[1]-v[0], v[3]-v[2] ].min DCL::grssim( vptsize*0.35*(90.0/map_radius), 0.0, 0.0 ) DCL::grstxy(-180.0, 180.0, 90.0-map_radius, 90.0) else DCL::grstxy(-180.0, 180.0, 90.0-map_radius, 90.0) end sv = DCL.umpget('lglobe') DCL.umpset('lglobe', true) DCL::umpfit DCL.umpset('lglobe', sv) else raise "unsupported transformation number: #{itr}" end DCL.grstrf DCL.umpset('lglobe', sv) if (!opts['new_frame']) && opts['keep_axis_offset'] # RESTORE OFFSET VALUES (%w(XT XB YL YR)).each_with_index{|zs, izs| DCL::uzpset("ROFF#{zs}", offset_org[izs])} end nil end |
.gropn_1_if_not_yet ⇒ Object
1179 1180 1181 1182 1183 |
# File 'lib/numru/ggraph.rb', line 1179 def gropn_1_if_not_yet if DCL.sgpget("iws") == 0 DCL.gropn(1) end end |
.histogram(gphys, newframe = true, options = nil) ⇒ Object Also known as: histogram1D
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/numru/ganalysis/histogram.rb', line 171 def histogram(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true of false" end unless gphys.rank == 1 raise ArgumentError, "rank of gphys must be 1" end unless gphys.axis(0).cell? raise ArgumentError, "axis must be cell type" end # if window is specified via GGraph#fig or GGraph#set_fig, use it. opts = @@histogram_options.interpret() exchange = opts["exchange"] raise "Option 'window' must be an Array of length == 4" unless opts["window"].is_a?(Array) && opts["window"].length == 4 window = opts["window"].dup 4.times{|i| window[i] ||= @@fig['window'][i]} if @@fig['window'] 4.times{|i| window[i] ||= DCL::sgqwnd[i]} unless newframe unless exchange x = gphys.axis(0).cell_bounds y = gphys window[2] ||= 0 else y = gphys.axis(0).cell_bounds x = gphys window[0] ||= 0 end itr = @@fig['itr'] || DCL::sgpget("itr") if (itr==2 || itr==4) tmp = y.val if tmp.min * tmp.max < 0 if tmp.min.abs < tmp.max mask = tmp.lt(0) else mask = tmp.gt(0) end else mask = tmp.ne(0) end if tmp.is_a?(NArrayMiss) tmp.set_mask(mask * tmp.get_mask) else tmp = NArrayMiss.to_nam_no_dup(tmp, mask) end y.replace_val(tmp) if(window[2].nil? || window[2] == 0) window[2] = tmp.abs.min * (tmp.min < 0 ? -1 : 1) end end if (itr==3 || itr==4) tmp = x.val if tmp.min * tmp.max < 0 if tmp.min.abs < tmp.max mask = tmp.lt(0) else mask = tmp.gt(0) end else mask = tmp.ne(0) end if tmp.is_a?(NArrayMiss) tmp.set_mask(mask * tmp.get_mask) else tmp = NArrayMiss.to_nam_no_dup(tmp, mask) end x.replace_val(tmp) if(window[0].nil? || window[0] == 0) window[0] = tmp.abs.min * (tmp.min < 0 ? -1 : 1) end end opts["window"] = window fig(x, y, "window" => window) if newframe lmiss = DCL::gllget("lmiss") DCL::gllset("lmiss", true) if opts["fill"] itps = DCL::uuqarp itps[0] = itps[1] = opts["fill_pattern"] if opts["fill_pattern"] DCL::uusarp(*itps) end unless exchange if opts["fill"] DCL::uvbxa(x.val, [window[2]] * y.length, y.val) end bottom = [window[2]] * y.length DCL::uvbxf(x.val, bottom, y.val) else if opts["fill"] DCL::uhbxa([window[0]] * x.length, x.val, y.val) end bottom = [window[0]] * x.length DCL::uhbxf(bottom, x.val, y.val) end DCL::gllset("lmiss", lmiss) axes(x, y, "title" => opts["title"]) if newframe return nil end |
.itr_is?(itr, fig_yet_to_be_called = false) ⇒ Boolean
1305 1306 1307 |
# File 'lib/numru/ggraph.rb', line 1305 def itr_is?( itr, fig_yet_to_be_called=false ) itr == current_itr( fig_yet_to_be_called ) end |
.line(gphys, newframe = true, options = nil) ⇒ Object
2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 |
# File 'lib/numru/ggraph.rb', line 2163 def line(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end if @@next_line = ( ? @@next_line.update() : @@next_line ) @@next_line = nil end opts = @@line_options.interpret() x, y, closer, gp, window = data_prep_1D(gphys, opts) if newframe fig(x, y, {'window'=>window}) if opts['proc_before_ax'] opts['proc_before_ax'].call end axes_or_map_and_ttl(gp, opts, x, y) end if opts['label'] lcharbk = DCL.sgpget('lchar') DCL.sgpset('lchar',true) DCL.sgsplc(opts['label']) end if opts['step_plot'] if opts['exchange'] yval = set_step_plot_position(y.val, opts['step_position']) DCL.uhbxlz(x.val, yval, opts['type'], opts['index']) else xval = set_step_plot_position(x.val, opts['step_position']) DCL.uvbxlz(xval, y.val, opts['type'], opts['index']) end else DCL.uulinz(x.val, y.val, opts['type'], opts['index']) end DCL.sgpset('lchar',lcharbk) if opts['label'] legend = opts['legend'] if legend legend = gp.name if legend==true DCLExt::legend(legend,opts['type'],opts['index'],true, opts['legend_size'],opts['legend_vx'],opts['legend_dx'], opts['legend_vy'],newframe) end closer.call if closer nil end |
.map(options = nil) ⇒ Object
1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
# File 'lib/numru/ggraph.rb', line 1875 def map(=nil) if @@next_map = ( ? @@next_map.update() : @@next_map ) @@next_map = nil end opts = @@map.interpret() DCL.umplim if opts['lim'] DCL.umpset('dgridmj',opts['dgridmj']) if opts['dgridmj'] DCL.umpset('dgridmn',opts['dgridmn']) if opts['dgridmn'] DCL.umpgrd if opts['grid'] if opts['vpt_boundary'] if opts['vpt_boundary'].is_a?(Integer) idx = opts['vpt_boundary'] else idx = 1 end DCL.slpvpr( idx ) end if opts['wwd_boundary'] if opts['wwd_boundary'].is_a?(Integer) idx = opts['wwd_boundary'] else idx = 1 end DCL.slpwwr( idx ) end DCL.umpmap('coast_world') if opts['coast_world'] DCL.umpmap('coast_japan') if opts['coast_japan'] if opts['fill'] DCL.umfmap('coast_world') if opts['coast_world'] DCL.umfmap('coast_japan') if opts['coast_japan'] end DCL.umpmap('border_world') if opts['border_world'] DCL.umpmap('plate_world') if opts['plate_world'] DCL.umpmap('state_usa') if opts['state_usa'] DCL.umpmap('pref_japan') if opts['pref_japan'] nil end |
.map_trn?(fig_yet_to_be_called = false) ⇒ Boolean
1296 1297 1298 1299 1300 1301 1302 1303 |
# File 'lib/numru/ggraph.rb', line 1296 def map_trn?( fig_yet_to_be_called=false ) if fig_yet_to_be_called itr = ( @@next_fig && @@next_fig['itr'] ) || @@fig['itr'] else itr = DCL.sgqtrn end !((1..9).include?(itr) || (51..99).include?(itr)) end |
.margin_info(program = nil, data_source = nil, char_height = nil, date = nil, xl = 0.0, xr = 0.0, yb = nil, yt = 0.0) ⇒ Object
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
# File 'lib/numru/ggraph.rb', line 1185 def margin_info(program=nil, data_source=nil, char_height=nil, date=nil, xl=0.0, xr=0.0, yb=nil, yt=0.0) program = File.($0) if !program if date program = __shorten_path(program,77) if DCL::DCLVERSION < "7.1" program += ' ' + Date.today.to_s else program = __shorten_path(program,99) if DCL::DCLVERSION < "7.1" if date.nil? && ## date is not added if false (DCL::DCLVERSION >= "7.1" || program.length < 77) program += ' ' + Date.today.to_s end end if !data_source data_source = Dir.pwd data_source = '' if data_source == program.sub(/\/[^\/]+$/,'') end data_source = __shorten_path(data_source,99) if DCL::DCLVERSION < "7.1" sz = 1.0/( program.length + data_source.length ) char_height = [0.008, sz].min if !char_height yb = 2.0 * char_height if !yb DCL.slmgn(xl, xr, yb, yt) DCL.slsttl(program, 'b', -1.0, -1.0, char_height, 1) DCL.slsttl(data_source, 'b', 1.0, -1.0, char_height, 2) nil end |
.mark(gphys, newframe = true, options = nil) ⇒ Object
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 |
# File 'lib/numru/ggraph.rb', line 2288 def mark(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end if @@next_mark = ( ? @@next_mark.update() : @@next_mark ) @@next_mark = nil end opts = @@mark_options.interpret() x, y, closer, gp, window = data_prep_1D(gphys, opts, len1ok: true) if newframe fig(x, y, {'window'=>window}) if opts['proc_before_ax'] opts['proc_before_ax'].call end axes_or_map_and_ttl(gp, opts, x, y) end DCL.uumrkz(x.val, y.val, opts['type'], opts['index'], opts['size']) legend = opts['legend'] if legend legend = gp.name if legend==true DCLExt::legend(legend,opts['type'],opts['index'],false, opts['legend_size'],opts['legend_vx'],nil, opts['legend_vy'],newframe,opts['size']) end closer.call if closer nil end |
.name_selector(gp, limit) ⇒ Object
2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 |
# File 'lib/numru/ggraph.rb', line 2596 def name_selector(gp, limit) if gp.long_name && gp.name if gp.long_name.length > limit && gp.long_name.length > gp.name.length && !gp.name.empty? gp.name else gp.long_name end else gp.long_name || gp.name end end |
.next_axes(options) ⇒ Object
1619 1620 1621 1622 1623 1624 1625 1626 |
# File 'lib/numru/ggraph.rb', line 1619 def next_axes() if .is_a?(Hash) @@next_axes = else raise TypeError,"Hash expected" end nil end |
.next_color_scatter(options) ⇒ Object
3029 3030 3031 3032 3033 3034 3035 3036 |
# File 'lib/numru/ggraph.rb', line 3029 def next_color_scatter() if .is_a?(Hash) @@next_color_scatter = else raise TypeError,"Hash expected" end nil end |
.next_contour(options) ⇒ Object
2576 2577 2578 2579 2580 2581 2582 2583 |
# File 'lib/numru/ggraph.rb', line 2576 def next_contour() if .is_a?(Hash) @@next_contour = else raise TypeError,"Hash expected" end nil end |
.next_fig(options) ⇒ Object
1287 1288 1289 1290 1291 1292 1293 1294 |
# File 'lib/numru/ggraph.rb', line 1287 def next_fig() if .is_a?(Hash) @@next_fig = else raise TypeError,"Hash expected" end nil end |
.next_line(options) ⇒ Object
2142 2143 2144 2145 2146 2147 2148 2149 |
# File 'lib/numru/ggraph.rb', line 2142 def next_line() if .is_a?(Hash) @@next_line = else raise TypeError,"Hash expected" end nil end |
.next_linear_contour_options(options) ⇒ Object
2334 2335 2336 2337 2338 2339 2340 2341 |
# File 'lib/numru/ggraph.rb', line 2334 def () if .is_a?(Hash) @@next_linear_contour_options = else raise TypeError,"Hash expected" end nil end |
.next_linear_tone_options(options) ⇒ Object
2738 2739 2740 2741 2742 2743 2744 2745 |
# File 'lib/numru/ggraph.rb', line 2738 def () if .is_a?(Hash) @@next_linear_tone_options = else raise TypeError,"Hash expected" end nil end |
.next_map(options) ⇒ Object
1866 1867 1868 1869 1870 1871 1872 1873 |
# File 'lib/numru/ggraph.rb', line 1866 def next_map() if .is_a?(Hash) @@next_map = else raise TypeError,"Hash expected" end nil end |
.next_mark(options) ⇒ Object
2279 2280 2281 2282 2283 2284 2285 2286 |
# File 'lib/numru/ggraph.rb', line 2279 def next_mark() if .is_a?(Hash) @@next_mark = else raise TypeError,"Hash expected" end nil end |
.next_regression_line(options) ⇒ Object
3333 3334 3335 3336 3337 3338 3339 3340 |
# File 'lib/numru/ggraph.rb', line 3333 def next_regression_line() if .is_a?(Hash) @@next_regression_line = else raise TypeError,"Hash expected" end nil end |
.next_scatter(options) ⇒ Object
2948 2949 2950 2951 2952 2953 2954 2955 |
# File 'lib/numru/ggraph.rb', line 2948 def next_scatter() if .is_a?(Hash) @@next_scatter = else raise TypeError,"Hash expected" end nil end |
.next_tone(options) ⇒ Object
2796 2797 2798 2799 2800 2801 2802 2803 |
# File 'lib/numru/ggraph.rb', line 2796 def next_tone() if .is_a?(Hash) @@next_tone = else raise TypeError,"Hash expected" end nil end |
.next_unit_vect_options(options) ⇒ Object
3182 3183 3184 |
# File 'lib/numru/ggraph.rb', line 3182 def () DCLExt.() end |
.next_vector(options) ⇒ Object
3226 3227 3228 3229 3230 3231 3232 3233 |
# File 'lib/numru/ggraph.rb', line 3226 def next_vector() if .is_a?(Hash) @@next_vector = else raise TypeError,"Hash expected" end nil end |
.polar_coordinate_boundaries(xax = nil, yax = nil) ⇒ Object
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 |
# File 'lib/numru/ggraph.rb', line 1824 def polar_coordinate_boundaries(xax=nil,yax=nil) slln=DCL.sgpget('LLNINT') ; slgc=DCL.sgpget('LGCINT') DCL.sgpset('LLNINT',true) ; DCL.sgpset('LGCINT',true) xmin=xax.min ; xmax=xax.max ; ymin=yax.min ; ymax=yax.max azimuth_len = ymax-ymin azimuth_len = azimuth_len.val if azimuth_len.is_a?(UNumeric) unless( (azimuth_len - 360.0).abs < 1e-2 ) # not a full circle DCL.sgplzu([xmin,xmax],[ymin,ymin],1,5) DCL.sgplzu([xmin,xmax],[ymax,ymax],1,5) end DCL.sgplzu([xmin,xmin],[ymin,ymax],1,5) DCL.sgplzu([xmax,xmax],[ymin,ymax],1,5) DCL.sgpset('LLNINT',slln) ; DCL.sgpset('LGCINT',slgc) nil end |
.profile(gphys, newframe = true, options = nil) ⇒ Object
———————————————————- Added at 080207 –
2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 |
# File 'lib/numru/ggraph.rb', line 2211 def profile(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end opts = @@line_options.interpret() check_max = opts['max'] opts['max'] = nil opts['exchange']= true x, y, closer, gp, window = data_prep_1D(gphys, opts) if newframe fig(x, y, {'window'=>window}) axes_or_map_and_ttl(gp, opts, x, y) end if opts['label'] lcharbk = DCL.sgpget('lchar') DCL.sgpset('lchar',true) DCL.sgsplc(opts['label']) end if opts['index'] iat=opts['index'] end if check_max if x.val.max > check_max iat=21 end end DCL.uulinz(x.val, y.val, opts['type'], iat ) DCL.sgpset('lchar',lcharbk) if opts['label'] legend = opts['legend'] if legend legend = gp.name if legend==true DCLExt::legend(legend,opts['type'],opts['index'],true, opts['legend_size'],opts['legend_vx'],opts['legend_dx'], opts['legend_vy'],newframe) end closer.call if closer nil end |
.regression_line(x, y, options = nil) ⇒ Object
3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 |
# File 'lib/numru/ggraph.rb', line 3342 def regression_line(x,y, =nil) if @@next_regression_line = ( ? @@next_regression_line.update() : @@next_regression_line ) @@next_regression_line = nil end opts = @@regression_line_options.interpret() x = x.val if x.respond_to?(:val) # GPhys or VArray like y = y.val if y.respond_to?(:val) # GPhys or VArray like x = NArray.to_na(x) if x.is_a?(Array) y = NArray.to_na(y) if y.is_a?(Array) xs = x # scaled x: x or log(x) (see below) ys = y # scaled y: y or log(y) (see below) xlog = ylog = false # can be overwritten below itr = current_itr() case itr when 1 # nothing to do when 2 ys = NMMath.log(ys) ylog = true when 3 xs = NMMath.log(xs) xlog = true when 4 xs = NMMath.log(xs) ys = NMMath.log(ys) xlog = ylog = true else raise "Drawing a linear regression line is limited to itr = 1~4 (linear or log plots), while the current itr is #{itr}. (itr is a coordinate transformation parameter set by fig (or set_fig or next_fig).)" end y_given_x = !opts['x_given_y'] xr = NArray.sfloat(2) # --> x ends of the regression line yr = NArray.sfloat(2) # --> y ends of the regression line if y_given_x a,b,r = linear_regression(xs,ys) if opts["limit"] xr[0] = x.min xr[1] = x.max else xr[0],xr[1], = DCL.sgqwnd end xrs = !xlog ? xr : NMath::log(xr) yrs = a + b*xrs yr = !ylog ? yrs : NMath::exp(yrs) else a,b,r = linear_regression(ys,xs) if opts["limit"] yr[0] = y.min yr[1] = y.max else dum0,dum1, yr[0], yr[1] = DCL.sgqwnd end yrs = !ylog ? yr : Math::log(yr) xrs = a + b*yrs xr = !xlog ? xrs : Math::exp(xrs) end before = DCLExt.sg_set_params({'lclip'=>opts['clip']}) DCL.sgplzu(xr,yr,opts["type"],opts["index"]) DCLExt.sg_set_params(before) ai = opts['annot_intercept'] || opts['annot_intercept'].nil? && itr==1 as = opts['annot_slope'] || opts['annot_slope'].nil? && (itr==1 or itr==4) ac = opts['annot_cor'] ar2 = opts['annot_r2'] if as && ai if y_given_x annot = ["regr y=a+bx:", " a=#{DCL.chval('A',a)}", " b=#{DCL.chval('A',b)}"] else annot = ["regr x=a+by:", " a=#{DCL.chval('A',a)}", " b=#{DCL.chval('A',b)}"] end annot.push(sprintf("r=%-.3g",r)) if ac annot.push(sprintf("r2=%-.3g",r**2)) if ar2 annotate(annot, @@nannot) elsif as if y_given_x annot = ["slope: #{DCL.chval('A',b)}"] else annot = ["regress x given y:", " x(y) slope: #{DCL.chval('A',b)}"] end annot.push(sprintf("r=%-.3g",r)) if ac annot.push(sprintf("r2=%-.3g",r**2)) if ar2 annotate(annot, @@nannot) end [a,b,r] end |
.scatter(fx, fy, newframe = true, options = nil) ⇒ Object
2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 |
# File 'lib/numru/ggraph.rb', line 2957 def scatter(fx, fy, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "3rd arg (newframe) must be true or false" end if @@next_scatter = ( ? @@next_scatter.update() : @@next_scatter ) @@next_scatter = nil end opts = @@scatter_options.interpret() # interpret cut, slice, etc gpx, closerx = data_prep_multidim(fx, opts) gpy, closery = data_prep_multidim(fy, opts) # flatten gphys data ----- fakeaxis = Axis.new.set_pos(VArray.new(NArray.int(gpx.length).indgen!, {"long_name"=>"fake", "units"=>""}, "fake")) fakegrid = Grid.new(fakeaxis) gpx, gpy = [gpx, gpy].collect{|gp| na = gp.val.reshape!(gp.length) attr = gp.data.attr_copy newgp = GPhys.new(fakegrid,VArray.new(na,attr,gp.name)) newgp.set_lost_axes(gp.lost_axes) newgp } # ------------------------ x = gpx.data y = gpy.data if newframe fig(x, y) if opts['proc_before_ax'] opts['proc_before_ax'].call end axes_or_map_and_ttl(gpx, opts, x, y, gpy) end DCL.uumrkz(x.val, y.val, opts['type'], opts['index'], opts['size']) if opts['correlation'] return _scatter_display_corr(gpx, gpy, opts) else return nil end # close if necessary ----- closerx.call if closerx closery.call if closery nil end |
.set_axes(options) ⇒ Object
1614 1615 1616 |
# File 'lib/numru/ggraph.rb', line 1614 def set_axes() @@axes.set() end |
.set_color_scatter(options) ⇒ Object
@@color_scatter_options.delete(“transpose”) # delete is yet to be supported @@color_scatter_options.delete(“exchange”) # (2010-01)
3025 3026 3027 |
# File 'lib/numru/ggraph.rb', line 3025 def set_color_scatter() @@color_scatter_options.set() end |
.set_contour(options) ⇒ Object
2571 2572 2573 |
# File 'lib/numru/ggraph.rb', line 2571 def set_contour() @@contour_options.set() end |
.set_contour_levels(options) ⇒ Object
2553 2554 2555 2556 |
# File 'lib/numru/ggraph.rb', line 2553 def set_contour_levels() opts = @@contour_levels.interpret() _set_contour_levels_(opts) end |
.set_fig(options) ⇒ Object
1282 1283 1284 |
# File 'lib/numru/ggraph.rb', line 1282 def set_fig() @@fig.set() end |
.set_line(options) ⇒ Object
2137 2138 2139 |
# File 'lib/numru/ggraph.rb', line 2137 def set_line() @@line_options.set() end |
.set_linear_contour_options(options) ⇒ Object
2330 2331 2332 |
# File 'lib/numru/ggraph.rb', line 2330 def () @@linear_contour_options.set() end |
.set_linear_tone_options(options) ⇒ Object
2734 2735 2736 |
# File 'lib/numru/ggraph.rb', line 2734 def () @@linear_tone_options.set() end |
.set_map(options) ⇒ Object
1861 1862 1863 |
# File 'lib/numru/ggraph.rb', line 1861 def set_map() @@map.set() end |
.set_mark(options) ⇒ Object
2274 2275 2276 |
# File 'lib/numru/ggraph.rb', line 2274 def set_mark() @@mark_options.set() end |
.set_regression_line(options) ⇒ Object
3329 3330 3331 |
# File 'lib/numru/ggraph.rb', line 3329 def set_regression_line() @@regression_line_options.set() end |
.set_scatter(options) ⇒ Object
@@scatter_options.delete(“transpose”) # delete is yet to be supported @@scatter_options.delete(“exchange”) # (2010-01)
2944 2945 2946 |
# File 'lib/numru/ggraph.rb', line 2944 def set_scatter() @@scatter_options.set() end |
.set_step_plot_position(val, postype) ⇒ Object
2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 |
# File 'lib/numru/ggraph.rb', line 2151 def set_step_plot_position(val, postype) if postype == 0 val = NArray.to_na([val[0]] + (val[0..-2] + val[1..-1]).mul!(0.5).to_a + [val[-1]]) elsif postype > 0 val = NArray.to_na([val[0]] + val.to_a) else val = NArray.to_na(val.to_a + [val[-1]]) end return val end |
.set_tone(options) ⇒ Object
2791 2792 2793 |
# File 'lib/numru/ggraph.rb', line 2791 def set_tone() @@tone_options.set() end |
.set_tone_levels(options) ⇒ Object
2754 2755 2756 2757 |
# File 'lib/numru/ggraph.rb', line 2754 def set_tone_levels() opts = @@tone_levels.interpret() _set_tone_levels_(opts) end |
.set_unit_vect_options(options) ⇒ Object
< vector >
3179 3180 3181 |
# File 'lib/numru/ggraph.rb', line 3179 def () DCLExt.() end |
.set_vector(options) ⇒ Object
3222 3223 3224 |
# File 'lib/numru/ggraph.rb', line 3222 def set_vector() @@vector_options.set() end |
.sim_trn? ⇒ Boolean
1318 1319 1320 |
# File 'lib/numru/ggraph.rb', line 1318 def sim_trn? (5..7).include?(DCL.sgqtrn) end |
.startup(options = nil) ⇒ Object
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
# File 'lib/numru/ggraph.rb', line 1159 def startup(=nil) opts = @@startup_options.interpret() DCL.swpset('iwidth',opts['iwidth']) if opts['iwidth'] DCL.swpset('iheight',opts['iheight']) if opts['iheight'] DCL.swpset('ifl',opts['ifl']) if opts['ifl'] && DCL::DCLVERSION >= "6" DCL.sgscmn(opts['colormap']) if opts['colormap'] DCL.swpset('lwait',opts['lwait']) DCL.swpset('lalt',opts['lalt']) DCL.gropn(opts['iws']) DCL.sgpset('isub', opts['isub']) DCL.glpset('lmiss', opts['lmiss']) DCL.sgpset('lfull',opts['lfull']) end |
.timeplot(gphys, newframe = true, options = nil) ⇒ Object
timeplot 0802011 ######
2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 |
# File 'lib/numru/ggraph.rb', line 2344 def timeplot(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end if ! defined?(@@timeplot_options) @@timeplot_options = Misc::KeywordOptAutoHelp.new( ['size', 0.01, 'marks size'], ['lamin', nil, 'minimam latitude value'], ['lamax', nil, 'maximam latitude value'], ['lomin', nil, 'minimam longitude value'], ['lomax', nil, 'maximam longitude value'], ['ltone', true, 'Same as udpack parameter ltone'], ['tonf', false, 'Use DCL.uetonf instead of DCL.uetone'], ['tonb', false, 'Use DCL.uetonb instead of DCL.uetone'], ['tonc', false, 'Use DCL.uetonc instead of DCL.uetone'], ['clr_min', 13, 'if an integer (in 10..99) is specified, used as the color number for the minimum data values. (the same can be done by setting the uepack parameter "icolor1")'], ['clr_max', 99, 'if an integer (in 10..99) is specified, used as the color number for the maximum data values. (the same can be done by setting the uepack parameter "icolor2")'], ['keep', false, 'Use the tone levels and patterns used previously'], @@line_options ) end opts = @@timeplot_options.interpret() opts['type'] = 2 if opts['clr_min'] icolor1_bak = DCL.uepget('icolor1') DCL.uepset('icolor1', opts['clr_min']) end if opts['clr_max'] icolor2_bak = DCL.uepget('icolor2') DCL.uepset('icolor2', opts['clr_max']) end cmn=opts['clr_min']+1 cmx=opts['clr_max']-1 if opts['lamin'] && opts['lamax'] latmn= opts['lamin'] latmx= opts['lamax'] if latmn > latmx raise ArgumentError,"Specific Settings parameter is invalid.(1)" end elsif opts['lamin'] || opts['lamax'] raise ArgumentError,"Specific Settings parameter is invalid.(2)" else latmn=false latmx=false end if opts['lomin'] && opts['lomax'] lonmn= opts['lomin'] lonmx= opts['lomax'] if lonmn > lonmx raise ArgumentError,"Specific Settings parameter is invalid.(3)" end elsif opts['lomin'] || opts['lomax'] raise ArgumentError,"Specific Settings parameter is invalid.(4)" else lonmn=false lonmx=false end gp = gphys.first2D gp = gp.transpose(1,0) if opts['transpose'] || opts['exchange'] #-- x = gp.coord(0) y = gp.coord(1) zv = gp.data.val idim=0 case x.name.downcase when "time" idim=0 else case y.name.downcase when "time" idim=1 end end latp=VArray.new lonp=VArray.new lat_flag = false lon_flag = false if gp.has_assoccoord? gp.assoc_coords.coordnames.each do |auxname| if auxname == "Latitude" latp=gp.coord(auxname) lat_flag = true elsif auxname == "Longitude" lonp=gp.coord(auxname) lon_flag = true end end end #------ for color bar DCL.uwsgxa(x.val) DCL.uwsgya(y.val) if !opts['keep'] or DCL.ueqntl==0 if !opts['levels'] && opts['log'] levels, = DCLExt.quasi_log_levels_z(gp.data.val, opts['nlev'], opts['max'], opts['min'], opts['log_cycle']) rmiss = DCL.glrget('rmiss') levels.unshift(rmiss) if !opts['max'] && levels[0]<0 levels.push(rmiss) if !opts['max'] && levels[-1]>0 opts['levels'] = levels end if opts['levels'] backup = @@set_tone_levels _set_tone_levels_(opts) @@set_tone_levels = backup elsif opts['patterns'] raise "option 'patterns' is not effective unless 'levels' is specified" elsif !@@set_tone_levels && opts['ltone'] DCL.ueitlv DCLExt.ue_set_linear_levs(gp.data.val, opts) else DCL.ueitlv if !@@set_tone_levels end end #------- if newframe fig(x, y) axes_or_map_and_ttl(gp, opts, x, y) end zmn=gp.data.val.min zmx=gp.data.val.max zmax = ((cmx-cmn)+cmn).round*10+3 zmin = cmn.round*10+3 #------- xx=x.val.to_a yy=y.val.to_a plat=latp.val.to_a if lat_flag plon=lonp.val.to_a if lon_flag zz=zv k=0 for i in 0..yy.length-1 for j in 0..xx.length-1 tflg=0 idim == 0 ? h=j : h=i tflg=1 if latmn && latmx && ( plat[h] < latmn || plat[h] > latmx ) tflg=2 if lonmn && lonmx && ( plon[h] < lonmn || plon[h] > lonmx ) if tflg == 0 xx1=NArray.to_na(Array.new(1,xx[j]*1.0)) yy1=NArray.to_na(Array.new(1,yy[i]*1.0)) z = zz[j,i] if zz[j,i].is_a?(Numeric) z = zmn if zz[j,i].is_a?(Array) iz=((z-zmn)/(zmx-zmn)*(cmx-cmn)+cmn).round*10+3 DCL.uumrkz(xx1, yy1, 230, iz, 0.005 ) end k+=1 end end legend = opts['legend'] if legend legend = gp.name if legend==true DCLExt::legend(legend,opts['type'],opts['index'],false, opts['legend_size'],opts['legend_vx'],nil, opts['legend_vy'],newframe,opts['size']) end DCL.uepset('icolor1', icolor1_bak) if opts['clr_min'] DCL.uepset('icolor2', icolor2_bak) if opts['clr_max'] #----------------------------- color bar unit -- 08.01.31 ---- vx1, vx2, vy1, vy2 = DCL.sgqvpt x1=vx2+0.02 y1=vy1-0.02 if "#{gp.data.units}".length >0 DCL.sgtxzv(x1, y1, "#{gp.data.units}", 0.02, 0, -1 ,11 ) end #----------------------------------------- nil end |
.title(string) ⇒ Object
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 |
# File 'lib/numru/ggraph.rb', line 1222 def title(string) if string if map_trn? || itr_is?(5) v = DCL::sgqvpt txhgt = DCL.uzpget('rsizec2') # rsizec2: larger text vx = (v[0]+v[1])/2 vy = v[3] + (0.5 + DCL.uzpget('pad1')) * txhgt DCL::sgtxzr(vx , vy, string, txhgt, 0, 0, 3) else DCL.uxmttl('t',string,0.0) end end nil end |
.tone(gphys, newframe = true, options = nil) ⇒ Object
2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 |
# File 'lib/numru/ggraph.rb', line 2830 def tone(gphys, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end if @@next_tone = ( ? @@next_tone.update() : @@next_tone ) @@next_tone = nil end if @@next_linear_tone_options = ( ? @@next_linear_tone_options.update() : @@next_linear_tone_options ) @@next_linear_tone_options = nil end opts = @@tone_options.interpret() xax, yax, closer, gp = data_prep_2D([gphys], newframe, opts) if opts['clr_min'] icolor1_bak = DCL.uepget('icolor1') DCL.uepset('icolor1', opts['clr_min']) end if opts['clr_max'] icolor2_bak = DCL.uepget('icolor2') DCL.uepset('icolor2', opts['clr_max']) end if newframe fig(xax, yax) end if opts['proc_before_tone'] opts['proc_before_tone'].call end DCL.uwsgxa(xax.val) if xax.rank==1 DCL.uwsgya(yax.val) if yax.rank==1 if !opts['keep'] or DCL.ueqntl==0 if !opts['levels'] && opts['log'] levels, = DCLExt.quasi_log_levels_z(gp.data.val, opts['nlev'], opts['max'], opts['min'], opts['log_cycle']) rmiss = DCL.glrget('rmiss') levels.unshift(rmiss) if !opts['max'] && levels[0]<0 levels.push(rmiss) if !opts['max'] && levels[-1]>0 opts['levels'] = levels end if opts['levels'] backup = @@set_tone_levels _set_tone_levels_(opts) @@set_tone_levels = backup elsif opts['patterns'] raise "option 'patterns' is not effective unless 'levels' is specified" elsif !@@set_tone_levels && opts['ltone'] DCL.ueitlv DCLExt.ue_set_linear_levs(gp.data.val, opts) else DCL.ueitlv if !@@set_tone_levels end end @@used_fullcolor_tone = false val = gp.data.val if opts['fullcolor'] @@used_fullcolor_tone = true sopt = opts.dup.delete_if{|k,v| !DCLExt.shade_1_option_keys.include?(k)} DCLExt.ui_shade_1(val, sopt) elsif opts['tonb'] && opts['ltone'] DCL.uetonb(val) elsif opts['tonc'] && opts['ltone'] DCL.uetonc(val) elsif ( opts['ltone'] && ( opts['tonf'] || opts['auto'] && ( val.length >= TONE_TONF_THRES_SIZE || val.shape.min >= TONE_TONF_THRES_LEN ) ) ) DCL.uetonf(val) else DCL.uetone(val) end if newframe if opts['proc_before_ax'] opts['proc_before_ax'].call end axes_or_map_and_ttl(gp,opts, xax, yax) end DCL.uepset('icolor1', icolor1_bak) if opts['clr_min'] DCL.uepset('icolor2', icolor2_bak) if opts['clr_max'] if opts['color_bar'] cbunits = opts['cbunits'] cbunits = gphys.units.to_s if cbunits==true if @@used_fullcolor_tone "units"=>cbunits else "log"=>opts['log'], "units"=>cbunits end end closer.call if closer nil end |
.tone_and_contour(gphys, newframe = true, options = nil) ⇒ Object
2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 |
# File 'lib/numru/ggraph.rb', line 2524 def tone_and_contour(gphys, newframe=true, =nil) ? copt=@@contour_options.select_existent() : copt=nil ? topt=@@tone_options.select_existent() : topt=Hash.new topt = @@tone_options.interpret(topt) = topt["color_bar"] topt["color_bar"]=false if # color bar will be plotted after contour tone(gphys, newframe, topt) contour(gphys, false, copt) if cbunits = topt['cbunits'] cbunits = gphys.units.to_s if cbunits==true if @@used_fullcolor_tone "units"=>cbunits else "log"=>topt['log'], "units"=>cbunits end end end |
.vector(fx, fy, newframe = true, options = nil) ⇒ Object
3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 |
# File 'lib/numru/ggraph.rb', line 3235 def vector(fx, fy, newframe=true, =nil) gropn_1_if_not_yet if newframe!=true && newframe!=false raise ArgumentError, "2nd arg (newframe) must be true or false" end if @@next_vector = ( ? @@next_vector.update() : @@next_vector ) @@next_vector = nil end opts = @@vector_options.interpret() xax, yax, closer, fx, fy = data_prep_2D([fx,fy], newframe, opts) if newframe fig(xax, yax) end if newframe axes_or_map_and_ttl(fx, opts, xax, yax, fy) end itr = current_itr xaxv = xax.val yaxv = yax.val DCL.uwsgxa(xaxv) DCL.uwsgya(yaxv) oldindex = DCLExt.ug_set_params("index" => opts['index']) if opts['index'] if opts['unit_vect'] if (uvu=opts['uvunits']) case uvu when String un = uvu else raise("fx-fy units miss match") if fx.units != fy.units un = fx.units.to_s end uvopts = {'units'=>un} else uvopts = Hash.new end end if opts['flow_itr5'] if itr_is?(5) DCLExt.flow_itr5( fx, fy, opts['factor'], opts['unit_vect'] ) returnval = nil else raise "flow_itr5 option should use with itr=5." end elsif opts['flow_vect_anyproj'] || ( opts['flow_vect_anyproj'].nil? && opts['flow_vect'] && itr >=2 ) @@vfratio, @@flenmax = DCLExt.flow_vect_anyproj(fx.val, fy.val, xaxv, yaxv, opts['factor'], 1, 1, opts['distvect_map'], (opts['keep'] && @@vfratio), (opts['keep'] && @@flenmax), opts['polar_thinning'] ) returnval = { "vfratio"=> @@vfratio, "flenmax"=>@@flenmax } if opts['unit_vect'] len_unit = opts['len_unit'] || @@flenmax DCLExt.unit_vect_single(@@vfratio, len_unit, uvopts) end elsif opts['flow_vect'] uninfo = DCLExt.flow_vect(fx.val, fy.val, opts['factor'], 1, 1, (opts['keep']&& @@vxfxratio), (opts['keep'] && @@vyfyratio) ) @@vxfxratio, @@vyfyratio, = uninfo returnval = { "vxfxratio"=>@@vxfxratio, "vyfyratio"=>@@vyfyratio } if opts['unit_vect'] unless opts['max_unit_vect'] uninfo[2] = opts['ux_unit'] # nil or a Numeric to specify the len uninfo[3] = opts['uy_unit'] # nil or a Numeric to specify the len end DCLExt.unit_vect( *(uninfo+[uvopts]) ) end else before=DCLExt.ug_set_params({'lunit'=>true}) if opts['unit_vect'] DCL.ugvect(fx.val, fy.val) returnval = nil DCLExt.ug_set_params(before) if opts['unit_vect'] end DCLExt.ug_set_params(oldindex) if opts['index'] closer.call if closer returnval end |
.vector_on_merdional_section(fx, fy, newframe = true, options = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/numru/ggraph_on_merdional_section.rb', line 72 def vector_on_merdional_section(fx, fy, newframe=true, =nil) if ! defined?(@@vector_on_merdional_section_options) @@vector_on_merdional_section_options = Misc::KeywordOptAutoHelp.new( ['newfig', true, 'if false, do not cleared before figure setting.'], ['title', nil, 'Title of the figure(if nil, internally determined)'], ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'], ['transpose', false, 'if true, exchange x and y axes'], ['flow_vect', true, 'If true, use DCLExt::flow_vect to draw vectors; otherwise, DCL::ugvect is used.'], ['xintv', 1, '(Effective only if flow_vect) interval of data sampling in x'], ['yintv', 1, '(Effective only if flow_vect) interval of data sampling in y'], ['factor', 1.0, '(Effective only if flow_vect) scaling factor to strech/reduce the arrow lengths'], ['unit_vect', false, 'Show the unit vector'], ['use_before_scale', false, '(Effective only unless flow_vect) If true, use scale factor before vector.'], ['max_unit_vect', false, '(Effective only if flow_vect && unit_vect) If true, use the maximum arrows to scale the unit vector; otherwise, normalize in V coordinate.'] ) end opts = @@vector_on_merdional_section_options.interpret() fx = fx.first2D.copy fy = fy.first2D.copy sh = fx.shape if sh != fy.shape raise ArgumentError, "shapes of fx and fy do not agree with each other" end fx = fx.transpose(1,0) if opts['transpose'] fy = fy.transpose(1,0) if opts['transpose'] if ((xi=opts['xintv']) >= 2) idx = NArray.int(sh[0]/xi).indgen!*xi # [0,xi,2*xi,..] fx = fx[idx, true] fy = fy[idx, true] end if ((yi=opts['yintv']) >= 2) idx = NArray.int(sh[1]/yi).indgen!*yi # [0,yi,2*yi,..] fx = fx[true, idx] fy = fy[true, idx] end xax = fx.coord(0) yax = fy.coord(1) aphi_ax, z_ax, was_proportional_to_p = \ GPhys::EP_Flux::preparate_for_vector_on_merdional_section(xax, yax) if was_proportional_to_p itr = 2 else itr = 1 end if newframe nextfig = @@next_fig.dup if ( @@next_fig != nil ) # backup next_fig fig(xax, yax, {'itr'=>itr}) axes(xax, yax) if opts['title'] ttl = opts['title'] else fxnm = fx.data.get_att('long_name') || fx.name fynm = fy.data.get_att('long_name') || fy.name ttl = '('+fxnm+','+fynm+')' end title( ttl ) annotate(fx.lost_axes) if opts['annotate'] @@next_fig = nextfig if ( @@next_fig != nil ) end fig(aphi_ax, z_ax, {'new_frame'=>false, 'itr'=>1, 'yreverse'=>false}) \ if (opts['newfig']) DCL.uwsgxa(aphi_ax.val) DCL.uwsgya(z_ax.val) if opts['flow_vect'] if opts['use_before_scale'] vxfxratio = @@uninfo[0]; vxfyratio = @@uninfo[1] before=DCLExt.ug_set_params( {'LNRMAL'=>false, 'LMSG'=>false, 'XFACT1'=>1.0, 'YFACT1'=>1.0} ) DCL.ugvect(vxfxratio*fx.val, vxfyratio*fy.val) DCLExt.ug_set_params(before) if opts['unit_vect'] if opts['max_unit_vect'] DCLExt.unit_vect(*@@uninfo) else DCLExt.unit_vect(*@@uninfo[0..1]) end end else @@uninfo = DCLExt.flow_vect(fx.val, fy.val, opts['factor'] ) if opts['unit_vect'] if opts['max_unit_vect'] DCLExt.unit_vect(*@@uninfo) else DCLExt.unit_vect(*@@uninfo[0..1]) end end end else if opts['use_before_scale'] vxfxratio = @@uninfo[0]; vxfyratio = @@uninfo[1] before1=DCLExt.ug_set_params({'lunit'=>true}) if opts['unit_vect'] before2=DCLExt.ug_set_params( {'LNRMAL'=>false, 'LMSG'=>false, 'XFACT1'=>1.0, 'YFACT1'=>1.0} ) DCL.ugvect(vxfxratio*fx.val, vxfyratio*fy.val) DCLExt.ug_set_params(before1) if opts['unit_vect'] DCLExt.ug_set_params(before2) else before=DCLExt.ug_set_params({'lunit'=>true}) if opts['unit_vect'] DCL.ugvect(fx.val, fy.val) DCLExt.ug_set_params(before) if opts['unit_vect'] end nil end end |