Module: NumRu::DCLExt
- Defined in:
- lib/numru/dclext.rb
Constant Summary collapse
- Default_RGB_1D =
ICOLOR in uicrgb.f:
[ DCL.isgrgb(255,0,255), DCL.isgrgb(0,0,255), DCL.isgrgb(0,255,255), DCL.isgrgb(0,255,0), DCL.isgrgb(255,255,0), DCL.isgrgb(255,0,0), DCL.isgrgb(255,0,255) ]
- @@empty_hash =
<<< module data >>>
Hash.new
- @@ui_shade_1_options =
Misc::KeywordOptAutoHelp.new( ['min', nil, 'Numeric => specifies the value corresponding to the RGB map lower end (default: minimum data value). Note that the same color is used below this value.'], ['max', nil, 'Numeric => specifies the value corresponding to the RGB map upper end (default: maximum data value). Note that the same color is used above this value.'], ['rgb', nil, '(Array/NArray) Specifies the color mapping. Example: [ DCL.isgrgb(0,0,0), DCL.isgrgb(255,255,255) ] for gray scale'], ['place_rgb', nil, '(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_ui_shade_1_options =
nil
- @@ui_shade_1_called =
for ui_color_bar_1
false
- @@ui_color_bar_1_options =
Misc::KeywordOptAutoHelp.new( ["voff", nil, "how far is the bar from the viewport in the V coordinate"], ["vcent",nil, "center position of the bar in the V coordinate (VX or VY)"], ["vlength", 0.3, "bar length in the V coordinate"], ["vwidth", 0.02, "bar width in the V coordinate"], ["inffact", 1.9, "factor to change the length of triangle on the side for infinity (relative to 'vwidth')"], ["landscape", false, "if true, horizonlly long (along x axes)"], ["portrait", true, "if true, vertically long (along y axes)"], ["top", false, "place the bar at the top (effective if landscape)"], ["left", false, "place the bar in the left (effective if portrait)"], ["units", nil, "units of the axis of the color bar"], ["units_voff", 0.0, "offset value for units from the default position in the V coordinate (only for 'units' != nil)"], ["title", nil, "title of the color bar"], ["title_voff", 0.0, "offset value for title from the default position in the V coordinate (only for 'title' != nil)"], ["tickintv", 1, "0,1,2,3,.. to specify how frequently the dividing tick lines are drawn (0: no tick lines, 1: every time, 2: ever other:,...)"], ["charfact", 0.9, "factor to change the label/units/title character size (relative to 'rsizel1')"], ["index", nil, "index of tick lines and bar frame"], ["charindex", nil, "index of labels, units, and title"], ["chval_fmt", nil, "string to specify the DCL.chval format for labeling"] )
- @@datetime_ax_options =
<<< Date and time axes (moved from dclext_datetime_ax.rb) >>>
Misc::KeywordOptAutoHelp.new( ['yax', false, 'true => y-axis, false => x-axis'], ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'], ['dtick1', 1, 'small tick interval in hours'], ['dtick2', nil, 'large tick (with hour labels) interval in hours'], ['year', false, 'true => add year to date label'], ['month', true, 'true => add month to date label'] )
- @@date_ax_options =
<<< Date axes >>>
Misc::KeywordOptAutoHelp.new( ['yax', false, 'true => y-axis, false => x-axis'], ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'], ['margin_factor', 0.9, 'Factor to control the extent to use UCPACK; The smaller, the less, requiring more space between year labels'], ['dtick1', nil, '(For long time series) small tick interval (years)'], ['dtick2', nil, '(For long time series) large tick with year labels (years)'] )
- @@lon_ax_options =
<<< longitude/latitude axes package >>>
Misc::KeywordOptAutoHelp.new( ['yax', false, 'true => y-axis, false => x-axis'], ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'], ['dtick1', nil, 'Interval of small tickmark (if nil, internally determined)'], ['dtick2', nil, 'Interval of large tickmark with labels (if nil, internally determined)'] )
- @@lat_ax_options =
Misc::KeywordOptAutoHelp.new( ['xax', false, 'true => x-axis, false => y-axis'], ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'], ['dtick1', nil, 'Interval of small tickmark (if nil, internally determined)'], ['dtick2', nil, 'Interval of large tickmark with labels (if nil, internally determined)'] )
- @@unit_vect_options =
Misc::KeywordOptAutoHelp.new( ['vxunit', 0.05, "x unit vect len in V coord. Used only when fxunit is omitted (default)"], ['vyunit', 0.05, "y unit vect len in V coord. Used only when fyunit is omitted (default)"], ['vxuloc', nil, "Starting x position of unit vect"], ['vyuloc', nil, "Starting y position of unit vect"], ['vxuoff', 0.05, "Specify vxuloc by offset from right-bottom corner"], ['vyuoff', 0.0, "Specify vyuloc by offset from right-bottom corner"], ['inplace',true, "Whether to print labels right by the unit vector (true) or below the x axis (false)"], ['rsizet', nil, "Label size(default taken from uz-parameter 'rsizel1')"], ['index', 3," Line index of the unit vector"], ['vertical', true,"(used only in unit_vect_single) the unit vector is directed upward if true, to the right if not."] )
- @@next_unit_vect_options =
nil
- @@color_bar_options =
<<< color bar >>>
Misc::KeywordOptAutoHelp.new( ["levels", nil, "tone levels (if omitted, latest ones are used)"], ["patterns", nil, "tone patterns (~colors) (if omitted, latest ones are used)"], ["voff", nil, "how far is the bar from the viewport in the V coordinate"], ["vcent",nil, "center position of the bar in the V coordinate (VX or VY)"], ["vlength", 0.3, "bar length in the V coordinate"], ["vwidth", 0.02, "bar width in the V coordinate"], ["inffact", 2.25, "factor to change the length of triangle on the side for infinity (relative to 'vwidth')"], ["landscape", false, "if true, horizonlly long (along x axes)"], ["portrait", true, "if true, vertically long (along y axes)"], ["top", false, "place the bar at the top (effective if landscape)"], ["left", false, "place the bar in the left (effective if portrait)"], ["units", nil, "units of the axis of the color bar"], ["units_voff", 0.0, "offset value for units from the default position in the V coordinate (only for 'units' != nil)"], ["title", nil, "title of the color bar"], ["title_voff", 0.0, "offset value for title from the default position in the V coordinate (only for 'title' != nil)"], ["tickintv", 1, "0,1,2,3,.. to specify how frequently the dividing tick lines are drawn (0: no tick lines, 1: every time, 2: ever other:,...)"], ["labelintv", nil, "0,1,2,3,.. to specify how frequently labels are drawn (0: no labels, 1: every time, 2: ever other:,... default: internally determined)"], ["labels_ud", nil, "user-defined labels for replacing the default labels (Array of String)"], ["charfact", 0.9, "factor to change the label/units/title character size (relative to 'rsizel1')"], ["log", false, "set the color bar scale to logarithmic"], ["constwidth", false, "if true, each color is drawn with the same width"], ["index", nil, "index of tick lines and bar frame"], ["charindex", nil, "index of labels, units, and title"], ["chval_fmt", nil, "string to specify the DCL.chval format for labeling"] )
Class Method Summary collapse
-
.__truncate(float, order = 2) ⇒ Object
<<< flow vector package >>>.
- .color_bar(options = nil) ⇒ Object
- .color_bar_draw_infinity(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, sign, ipat, index) ⇒ Object
- .color_bar_draw_infinity_full(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, sign, icolor, index) ⇒ Object
- .color_bar_dual_log(levels, lv, patterns, portrait, opt) ⇒ Object
- .color_bar_title_units(vxmin, vxmax, vymin, vymax, portrait, voff, title, units, title_voff, units_voff) ⇒ Object
- .date_ax(date_from, date_to, options = nil) ⇒ Object
- .datetime_ax(date_from, date_to, options = nil) ⇒ Object
- .flow_itr5(gpx, gpy, factor = 1.0, unit_vect = false) ⇒ Object
- .flow_vect(fx, fy, factor = 1.0, xintv = 1, yintv = 1, vxfxratio = nil, vyfyratio = nil) ⇒ Object
- .flow_vect_anyproj(fx, fy, xg, yg, factor = 1.0, xintv = 1, yintv = 1, distvect_map = true, vfratio = nil, flenmax = nil, polar_thinning = nil) ⇒ Object
- .get_proj_params ⇒ Object
- .lat_ax(options = nil) ⇒ Object
-
.legend(str, type, index, line = false, size = nil, vx = nil, dx = nil, vy = nil, first = true, mark_size = nil) ⇒ Object
Annotates line/mark type and index (and size if mark).
- .level_chval_fmt(max, min, dx) ⇒ Object
- .log10_or_0(val) ⇒ Object
- .log10_safe(val) ⇒ Object
- .lon_ax(options = nil) ⇒ Object
- .next_ui_shade_1_options(options) ⇒ Object
- .next_unit_vect_options(options) ⇒ Object
-
.quasi_log_levels(lev0, lev1, cycle = 1) ⇒ Object
Returns approximately log-scaled contour/tone levels as well as major/minor flags for contours.
-
.quasi_log_levels_z(vals, nlev = nil, max = nil, min = nil, cycle = 1) ⇒ Object
Driver of quasi_log_levels with data values.
-
.restore_proj_params(hash) ⇒ Object
hash: OUTPUT OF DCLExt::get_proj_params.
- .set_color_bar_options(options) ⇒ Object
- .set_ui_shade_1_options(options) ⇒ Object
- .set_unit_vect_options(options) ⇒ Object
- .shade_1_option_keys ⇒ Object
-
.sht_get_m(mm) ⇒ Object
calcurate m (zonal wavenum).
-
.sht_get_n(mm) ⇒ Object
calcurate n (total wavenum).
- .sprintf_level(x, max, min, dx) ⇒ Object
- .ud_add_contour(levels, index = nil, line_type = nil, label = nil, label_height = nil) ⇒ Object
-
.ud_coloring(clr_min = 13, clr_max = 99) ⇒ Object
<<< udpack >>>.
- .ud_set_contour(*args) ⇒ Object
- .ud_set_linear_levs(v, options = nil) ⇒ Object
- .ue_add_tone(levels, patterns) ⇒ Object
-
.ue_linear_levels(min, max, dx, lbound = false, inf_min = false, inf_max = false) ⇒ Object
Same as level setting in uegtla but supporting extension to infinity.
-
.ue_set_linear_levs(v, options = nil) ⇒ Object
options: ‘min’ Numeric minimum tone level ‘max’ Numeric maximum tone level ‘nlev’ Integer number of levels ‘interval’ Numeric tone-level interval ‘inf_max’ true/false to set (or not) the maximum tone level to infty ‘inf_min’ true/false to set (or not) the minimum tone level to infty ‘lbound’ true/false Same as uepack param LBOUND but default is false.
- .ue_set_tone(levels, patterns) ⇒ Object
-
.ue_set_tone_auto(levels) ⇒ Object
similar to uegtla/uegtlb but for levels are given.
- .ui_color_bar_1(options = nil) ⇒ Object
-
.ui_shade_1(z, options = nil) ⇒ Object
A wrapper of UIPDAT supporting options.
-
.unit_vect(vxfxratio, vyfyratio, fxunit = nil, fyunit = nil, options = nil) ⇒ Object
(V cood length)/(actual length) in x.
- .unit_vect_single(vfratio, flen, options = nil) ⇒ Object
- .year_ax(xax, cside, date_from, date_to) ⇒ Object
Class Method Details
.__truncate(float, order = 2) ⇒ Object
<<< flow vector package >>>
1724 1725 1726 1727 1728 1729 1730 |
# File 'lib/numru/dclext.rb', line 1724 def __truncate(float, order=2) # truncate (round) a floating number with the number digits # specified by "order". # e.g., if order=3, -0.012345 => -0.0123; 6.6666 => 6.67 exponent = 10**(-Math::log10(float.abs).floor+order-1) (float * exponent).round.to_f/exponent end |
.color_bar(options = nil) ⇒ Object
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 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 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 2667 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 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 |
# File 'lib/numru/dclext.rb', line 2397 def (=nil) # < set parameters > opt = @@color_bar_options.interpret() lsetx = DCL.uwqgxz lsety = DCL.uwqgyz rmiss = DCL.glrget('rmiss') levels = opt['levels'] patterns = opt['patterns'] if (levels.nil? && !patterns.nil?) || (!levels.nil? && patterns.nil?) raise "levels and patterns must be set at same time\n" end landscape = opt["landscape"] || !opt["portrait"] portrait = !landscape ue_set_tone(levels, patterns) if !levels.nil? labels_ud = opt["labels_ud"] if (!labels_ud.nil? && ((labels_ud.class != Array) || labels_ud.empty? || labels_ud.map{|lud| lud.class == String}.include?(false))) raise ArgumentError, "'labels_ud' must be an Array of String" end # apply optional parameters for axes and labels index = opt["index"] || DCL::uziget("indext2") index = 1 if index <= 0 charindex = opt["charindex"] || DCL::uziget("indexl1") charindex = 1 if charindex <= 0 charfact = opt["charfact"] charfact = 1 if charfact < 0 rsizel1 = charfact * DCL::uzrget("rsizel1") axparam_bk = DCLExt.uz_set_params("indext1" => index, "indext2" => index, "indexl1" => charindex, "rsizel1" => rsizel1) nton = DCL::ueqntl raise "no tone patern was set\n" if nton == 0 lev1 = Array.new lev2 = Array.new patterns = Array.new if !opt['patterns'] for n in 0..nton-1 tlev1,tlev2,ipat = DCL::ueqtlv(n+1) lev1.push(tlev1) lev2.push(tlev2) patterns.push(ipat) if !opt['patterns'] end #levels = lev1+lev2 #levels = levels.uniq.sort #levels.delete(rmiss) #if levels.ne(levels.sort).any? # raise "levels is not in order\n" #end levels ||= lev1.push(lev2[-1]) levels = NArray.to_na(levels) if levels.is_a?(Array) patterns = NArray.to_na(patterns) if patterns.is_a?(Array) vx1, vx2, vy1, vy2 = DCL.sgqvpt if opt['log'] lv = levels[levels.ne(rmiss).where] if lv.length >= 4 && lv[0] * lv[-1] < 0 # log for both positive and negative DCLExt.(levels, lv, patterns, portrait, opt) DCLExt.uz_set_params(axparam_bk) return end end if levels.length <= 1 $stderr.print( "WARNING #{__FILE__}:#{__LINE__}: # of levels <= 1. No color bar is drawn." ) DCLExt.uz_set_params(axparam_bk) return end proj_params = DCLExt.get_proj_params # BACKUP PARAMS FOR PROJECTION vwidth = opt["vwidth"] vlength = opt["vlength"] # compute offset from main diagram if portrait if !opt["left"] # right voff = opt["voff"] || DCL.uzrget('roffyr') + DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vxmin = vx2 + voff vxmax = vx2 + voff + vwidth else # left voff = opt["voff"] ? -opt["voff"] : \ DCL.uzrget('roffyl') - DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vxmax = vx1 + voff vxmin = vx1 + voff - vwidth end vymin =( opt["vcent"] ? opt["vcent"]-vlength/2 : vy1 ) vymax =( opt["vcent"] ? opt["vcent"]+vlength/2 : vy1+vlength ) else ## landscape ## vxmin = (opt["vcent"] || ((vx1 + vx2) / 2)) - vlength / 2 vxmax = (opt["vcent"] || ((vx1 + vx2) / 2)) + vlength / 2 if opt["top"] # top voff = opt["voff"] || DCL.uzrget('roffxt') + DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vymin = vy2 + voff vymax = vy2 + voff + vwidth else # bottom voff = opt["voff"] ? -opt["voff"] : \ DCL.uzrget('roffxb') - DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vymax = vy1 + voff vymin = vy1 + voff - vwidth end end min = levels[levels.ne(rmiss).where].min max = levels[levels.ne(rmiss).where].max if (inf0 = (levels[0] == rmiss)) dummy1,dummy2,ipat0 = DCL::ueqtlv(1) if levels.length==2 DCLExt.uz_set_params(axparam_bk) return end end if (inf1 = (levels[-1] == rmiss)) dummy1,dummy2,ipat1 = DCL::ueqtlv(nton) if levels.length==2 DCLExt.uz_set_params(axparam_bk) return end end # < paint color tones > lclip_bk = DCLExt.sg_set_params("lclip" => false) inffact = opt["inffact"] # paint color tones for infinity (with drawing frame) if inf0 DCLExt.(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, -1, ipat0, index) end if inf1 DCLExt.(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, 1, ipat1, index) end # paint color tones for each range (with drawing long-side frame) if opt["constwidth"] levels = levels[(inf0 ? 1 : 0)..(inf1 ? -2 : -1)] patterns = patterns[(inf0 ? 1 : 0)..(inf1 ? -2 : -1)] nlev = levels.length npat = patterns.length if portrait vy = (NArray.sfloat(npat+1).indgen!)*(vymax-vymin)/npat + vymin # paint color tones for each range (with drawing long-side frame) for i in 0..npat-1 DCL::sgtnzv([vxmin, vxmax, vxmax, vxmin], vy[[i, i, i + 1, i + 1]], patterns[i]) end [vxmin, vxmax].each{|x| DCL::sgplzv([x] * 2, vy[[0, -1]], 1, index)} else ## landscape ## vx = (NArray.sfloat(npat+1).indgen!)*(vxmax-vxmin)/npat + vxmin # paint color tones for each range (with drawing long-side frame) for i in 0..npat-1 DCL::sgtnzv(vx[[i, i, i + 1, i + 1]], [vymin, vymax, vymax, vymin], patterns[i]) end [vymin, vymax].each{|y| DCL::sgplzv(vx[[0, -1]], [y] * 2, 1, index)} end else ### opt["constwidth"] == false ### # paint color tones for each range = 100 = NArray.float(,2) for i in 0..-1 [i,true] = min + (max-min).to_f/(-1)*i end labelxbyl_bk = DCLExt.uz_set_params("labelxb" => landscape, "labelyl" => portrait) if portrait cbwindow = [0.0, 1.0, min, max] = .transpose(-1,0) DCL::uwsgxa([0,1]) DCL::uwsgya([0,true]) else cbwindow = [min, max, 0.0, 1.0] DCL::uwsgxa([true,0]) DCL::uwsgya([0,1]) end type = 1 if opt["log"] type +=1 type +=1 if !portrait end DCL::grfig DCL::grsvpt(vxmin,vxmax,vymin,vymax) DCL::grswnd(*cbwindow) DCL::grstrn(type) DCL::grstrf DCL::uetone() DCL.uwsgxz(false) DCL.uwsgyz(false) end # < set ticking and labeling levels > if opt["labelintv"] labelintv = opt["labelintv"] else ntn = nton ntn -= 1 if inf0 ntn -= 1 if inf1 labelintv = (ntn - 1) / (portrait ? 9 : 5) + 1 end no_label = (labelintv <= 0) labelintv = 1 if no_label tickintv = opt["tickintv"] no_tick = (tickintv <= 0) tickintv = labelintv if no_tick eps = 1e-5 dummy = -9.9e-38 dz = dzp = dzc = dummy idu = Array.new (1...levels.length).each do |i| dzc = (levels[i] - levels[i-1]).abs if (dzc-dzp).abs <= eps * [dzc.abs,dzp.abs].max dz = dzc # set dz if two consecutive inrements are the same idu.push( i-1 ) end dzp = (levels[i] - levels[i-1]).abs end if idu.length > 0 idumin = idu.min - 1 idumax = idu.max + 1 else idumin = 0 idumax = levels.length-1 end if dz != dummy # if idumin == 1 and levels[0] != rmiss # # to correct non-uniform intv at the beginning # levels[0] = levels[1] - dz # idumin = 0 # min = levels[0] # end # if idumax == levels.length-2 and levels[-1] != rmiss # # to correct non-uniform intv at the end # levels[-1] = levels[-2] + dz # idumax = levels.length-1 # max = levels[-1] # end # use the algorithm used in DCL.udgcla offs_tick = ( (-levels[idumin]/dz).round % tickintv + idumin ) % tickintv offs_label = ( (-levels[idumin]/dz).round % labelintv + idumin ) % labelintv else md = 0 if ( (idx=levels.eq(0.0).where).length > 0 ) md = idx[0] % labelintv else a = levels[0...([labelintv,levels.length].min)] b = a * 10**( -NMath.log10(a.abs).floor.min ) (0...b.length).each{|i| md=i if (b[i].round-b[i]).abs < 1e-5 } end offs_tick = (md % tickintv) offs_label = md end if levels.length >= 4 lvmx = levels[1..-2].max lvmn = levels[1..-2].min dlv = (lvmx-lvmn) / (levels.length-3) elsif levels.length == 3 or levels.length == 2 lvmn = lvmx = dlv = levels[1] else lvmn = lvmx = dlv = levels[0] end # < draw units, title, labels, and tick lines> if opt["constwidth"] if !no_label && labels_ud ilbl = 0 for i in 0..nlev-1 if (i % labelintv) == offs_label ilbl += 1 end end if labels_ud.size != ilbl raise ArgumentError, "'labels_ud' must be an Array of length==#{ilbl} in this case" end end DCLExt.(vxmin, vxmax, vymin, vymax, portrait, voff, opt['title'], opt['units'], opt['title_voff'], opt['units_voff']) if portrait cent = ((voff > 0) ? -1 : 1) spacer = DCL::uzrget('pad1') * rsizel1 vxlabel = (voff > 0) ? (vxmax + spacer) : (vxmin - spacer) ilbl_ud = 0 for i in 0..nlev-1 # labels if !no_label && (i % labelintv) == offs_label if labels_ud char = labels_ud[ilbl_ud] DCL::sgtxzr(vxlabel, vy[i], char, rsizel1, 0, cent, charindex) ilbl_ud += 1 else begin if(opt['chval_fmt']) char = DCL::chval(opt['chval_fmt'],levels[i]) else char = sprintf_level(levels[i],lvmx,lvmn,dlv) end DCL::sgtxzr(vxlabel, vy[i], char, rsizel1, 0, cent, charindex) rescue DCL::sgtxzr(vxlabel, vy[i], levels[i].to_s, rsizel1, 0, cent, charindex) end end end # tick lines and short-side frame if (!no_tick && (i % tickintv) == offs_tick) || (!inf0 && i == 0) || (!inf1 && i == nlev-1) DCL::sgplzv([vxmin,vxmax],[vy[i],vy[i]],1,index) end end else ## landscape ## spacer = (0.5 + DCL::uzrget('pad1')) * rsizel1 tmpvy = [vymin - spacer, vymax + spacer] tmpvy = [tmpvy[1], tmpvy[0]] if voff <= 0 vylabel = tmpvy[1] ilbl_ud = 0 for i in 0..nlev-1 # labels if !no_label && (i % labelintv) == offs_label if labels_ud char = labels_ud[ilbl_ud] DCL::sgtxzr(vx[i], vylabel, char, rsizel1, 0, 0, charindex) ilbl_ud += 1 else begin if(opt['chval_fmt']) char = DCL::chval(opt['chval_fmt'],levels[i]) else char = sprintf_level(levels[i],lvmx,lvmn,dlv) end DCL::sgtxzr(vx[i], vylabel, char, rsizel1, 0, 0, charindex) rescue DCL::sgtxzr(vx[i], vylabel, levels[i].to_s, rsizel1, 0, 0, charindex) end end end # tick lines and short-side frame if (!no_tick && (i % tickintv) == offs_tick) || (!inf0 && i == 0) || (!inf1 && i == nlev-1) DCL::sgplzv([vx[i],vx[i]],[vymin,vymax],1,index) end end end else ### opt["constwidth"] == false ### inner_bk = DCLExt.uz_set_params('inner' => 1) tick1 = Array.new tick2 = Array.new for i in 0..levels.length-1 # if i>=idumin && i<=idumax && levels[i]!=rmiss if levels[i]!=rmiss tick1.push(levels[i]) if (i % tickintv) == offs_tick tick2.push(levels[i]) if (i % labelintv) == offs_label end end fmt = opt['chval_fmt'] || (opt["log"] ? "b" : DCLExt.level_chval_fmt(lvmx, lvmn, dlv)) rsizet12_bk = DCLExt.uz_set_params('rsizet1' => no_tick ? 0.0 : vwidth, 'rsizet2' => 0.0) if portrait if no_label before = DCLExt.uz_set_params(Hash[*(%w(xt xb yl yr).map{|zs| ["label#{zs}", false]}.flatten)]) else before = DCLExt.uz_set_params('labelyl' => (voff <= 0), 'labelyr' => (voff > 0), 'icentyr' => ((voff > 0) ? -1.0 : 1.0)) end # draw frame, tick lines, and labels cfmt_bk = DCL::uyqfmt DCL::uysfmt(fmt) if labels_ud if labels_ud.size != tick2.size raise ArgumentError, "'labels_ud' must be an Array of length==#{tick2.size} in this case" end nc = labels_ud.collect{|c| c.size}.max ["l", "r"].each{|cs| DCL::uyaxlb(cs, tick1, tick2, labels_ud, nc)} else ["l", "r"].each{|cs| DCL::uyaxnm(cs, tick1, tick2)} end DCL::uxaxdv("b",1,index) if !inf0 DCL::uxaxdv("t",1,index) if !inf1 DCL::uysfmt(cfmt_bk) else ## landscape ## if no_label before = DCLExt.uz_set_params(Hash[*(%w(xt xb yl yr).map{|zs| ["label#{zs}", false]}.flatten)]) else before = DCLExt.uz_set_params('labelxt' => (voff > 0), 'labelxb' => (voff <= 0)) end # draw frame, tick lines, and labels cfmt_bk = DCL::uxqfmt DCL::uxsfmt(fmt) if labels_ud if labels_ud.size != tick2.size raise ArgumentError, "'labels_ud' must be an Array of length==#{tick2.size} in this case" end nc = labels_ud.collect{|c| c.size}.max ["t", "b"].each{|cs| DCL::uxaxlb(cs, tick1, tick2, labels_ud, nc)} else ["t", "b"].each{|cs| DCL::uxaxnm(cs, tick1, tick2)} end DCL::uyaxdv("l",1,index) if !inf0 DCL::uyaxdv("r",1,index) if !inf1 DCL::uxsfmt(cfmt_bk) end DCLExt.(vxmin, vxmax, vymin, vymax, portrait, voff, opt['title'], opt['units'], opt['title_voff'], opt['units_voff']) # RESTORE PARAMS DCLExt.restore_proj_params(proj_params) DCLExt.uz_set_params(before) ### labelzs DCLExt.uz_set_params(rsizet12_bk) DCLExt.uz_set_params(labelxbyl_bk) if labelxbyl_bk DCLExt.uz_set_params(inner_bk) end DCLExt.uz_set_params(axparam_bk) DCLExt.sg_set_params(lclip_bk) nil end |
.color_bar_draw_infinity(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, sign, ipat, index) ⇒ Object
2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 |
# File 'lib/numru/dclext.rb', line 2286 def (vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, sign, ipat, index) sign = (sign > 0) ? 1 : -1 win = [vxmin, vxmax, vymin, vymax] win = win[2..3] + win[0..1] if portrait base = ((sign < 0) ? win[0] : win[1]) v3 = [[base, base + vwidth * inffact * sign, base], [win[2], (win[2] + win[3]) / 2, win[3]]] v3 = [v3[1], v3[0]] if portrait DCL.sgtnzv(v3[0], v3[1], ipat) DCL.sgplzv(v3[0], v3[1], 1, index) end |
.color_bar_draw_infinity_full(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, sign, icolor, index) ⇒ Object
2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 |
# File 'lib/numru/dclext.rb', line 2298 def (vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, sign, icolor, index) sign = (sign > 0) ? 1 : -1 win = [vxmin, vxmax, vymin, vymax] win = win[2..3] + win[0..1] if portrait base = ((sign < 0) ? win[0] : win[1]) v3 = [[base, base + vwidth * inffact * sign, base], [win[2], (win[2] + win[3]) / 2, win[3]]] v3 = [v3[1], v3[0]] if portrait DCL.sgtnxv(v3[0], v3[1], 455, icolor) DCL.sgplzv(v3[0], v3[1], 1, index) end |
.color_bar_dual_log(levels, lv, patterns, portrait, opt) ⇒ Object
2337 2338 2339 2340 2341 2342 2343 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 |
# File 'lib/numru/dclext.rb', line 2337 def (levels, lv, patterns, portrait, opt) rmiss = DCL::glrget("rmiss") vx1, vx2, vy1, vy2 = DCL::sgqvpt iturn = 0 for i in 0...levels.length if levels[i] != rmiss if levels[i] * lv[0] < 0 iturn = i break end end end opt['vlength'] /= 2 vc0 = opt['vcent'] || ( portrait && (vy1 + vy2) / 2) || (vx1 + vx2) / 2 zs = (portrait ? (opt["left"] ? "yl" : 'yr') : (opt["top"] ? "xt" : 'xb')) zssign = (zs == "xb" || zs == "yl") ? -1 : 1 opt["voff"] ||= DCL.uzrget('pad1') * DCL::uzrget("rsizec2") + DCL::uzrget("roff#{zs}") * zssign vsep2 = 0.02 has_zero = (levels[iturn - 1] == 0) # zero might be located just before the sign changes opt['levels'] = levels[0..(iturn - (has_zero ? 2 : 1))] opt['patterns'] = patterns[0..(iturn - (has_zero ? 3 : 2))] opt['vcent'] = vc0 - opt['vlength'] / 2 - vsep2 units = opt['units'] opt['units'] = nil DCLExt.(opt) opt['levels'] = levels[iturn..-1] opt['patterns'] = patterns[iturn..-1] opt['vcent'] = vc0 + opt['vlength'] / 2 + vsep2 opt['units'] = units DCLExt.(opt) # fill between the two bars bk = DCLExt.sg_set_params('lclip' => false) (has_zero ? 2 : 1).times{|i| if portrait sign = opt["left"] ? -1 : 1 base = opt["left"] ? vx1 : vx2 x1 = base + opt["voff"] * sign x2 = x1 + opt['vwidth'] * sign y1 = vc0 - ((has_zero && (i == 0)) ? 0 : vsep2) y2 = vc0 + ((has_zero && (i == 1)) ? 0 : vsep2) else x1 = vc0 - ((has_zero && (i == 0)) ? 0 : vsep2) x2 = vc0 + ((has_zero && (i == 1)) ? 0 : vsep2) sign = opt["top"] ? 1 : -1 base = opt["top"] ? vy2 : vy1 y1 = base + opt["voff"] * sign y2 = y1 + opt['vwidth'] * sign end DCL.sgtnzv([x1, x2, x2, x1], [y1, y1, y2, y2], patterns[iturn - 1 - (has_zero ? i : 0)]) DCL.sgplzv([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], 1, 3) } DCLExt.sg_set_params(bk) end |
.color_bar_title_units(vxmin, vxmax, vymin, vymax, portrait, voff, title, units, title_voff, units_voff) ⇒ Object
2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 |
# File 'lib/numru/dclext.rb', line 2310 def (vxmin, vxmax, vymin, vymax, portrait, voff, title, units, title_voff, units_voff) rsizel1 = DCL::uzrget('rsizel1') charindex = DCL::uziget('indexl1') pad1 = DCL::uzrget('pad1') if portrait if voff > 0 # title DCL::sgtxzr(vxmin - (0.5 + pad1) * rsizel1, (vymin + vymax) / 2.0 + title_voff, title, rsizel1, 90, 0, charindex) if title # units DCL::sgtxzr(vxmax + pad1 * rsizel1, vymax + 2.6 * rsizel1 + units_voff, units, rsizel1, 0, -1, charindex) if units else # title DCL::sgtxzr(vxmax + (0.5 + pad1) * rsizel1, (vymin + vymax) / 2.0 - title_voff, title, rsizel1, -90, 0, charindex) if title # units DCL::sgtxzr(vxmin - pad1 * rsizel1, vymax + 2.6 * rsizel1 + units_voff, units, rsizel1, 0, 1, charindex) if units end else spacer = (0.5 + pad1) * rsizel1 tmpvy = [vymin - spacer, vymax + spacer] tmpvy = [tmpvy[1], tmpvy[0]] if voff <= 0 # title DCL::sgtxzr((vxmin + vxmax) / 2.0 + title_voff, tmpvy[0], title, rsizel1, 0, 0, charindex) if title # units DCL::sgtxzr(vxmax + 2.6 * rsizel1 + units_voff, tmpvy[1], units, rsizel1, 0, -1, charindex) if units end end |
.date_ax(date_from, date_to, options = nil) ⇒ Object
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 |
# File 'lib/numru/dclext.rb', line 1462 def date_ax(date_from, date_to, =nil) # < intepret the options > opt = @@date_ax_options.interpret() mfact = opt['margin_factor'] yax = opt['yax'] xax = !yax if xax xy = 'x' cside= opt['cside'] || 'b' else xy = 'y' cside= opt['cside'] || 'l' end # < examine the time period to see wheterh to use UCPACK > irot = DCL.uzpget("irotc"+xy+cside) rsize = DCL.uzpget("rsizel2") nday = date_to - date_from ny = nday / 365.25 if (xax && irot%2 == 0) || (yax && irot%2 == 1) cw = (rsize*0.82)*4 # approximate width for 4 digits else cw = rsize end vx1,vx2,vy1,vy2 = DCL::sgqvpt if xax vw = (vx2-vx1)/ny else vw = (vy2-vy1)/ny end use_ucpack = (cw <= vw*mfact) # < draw the axes > if use_ucpack jd0 = date_from.strftime('%Y%m%d').to_i if xax DCL.ucxacl(cside,jd0,nday) else DCL.ucyacl(cside,jd0,nday) end else year_ax(xax, cside, date_from, date_to) end end |
.datetime_ax(date_from, date_to, options = nil) ⇒ Object
1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 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 |
# File 'lib/numru/dclext.rb', line 1300 def datetime_ax(date_from, date_to, =nil) # date_from [a DateTime] : start on this date&time # date_to [a DateTime] : end on this date&time opt = @@datetime_ax_options.interpret() yax = opt['yax'] xax = !yax if xax xy='x' else xy='y' end if opt['cside'] cside = opt['cside'] elsif opt['cside'].nil? if xax cside='b' else cside='l' end else if xax cside='t' else cside='r' end end if opt['year'] datefmt = '%Y/%m/%d' elsif opt['month'] datefmt = '%m/%d' else datefmt = '%d' end # < window parameters > ux1,ux2,uy1,uy2 = DCL.sgqwnd if xax u1, u2 = ux1, ux2 else u1, u2 = uy1, uy2 end if u1 > u2 u1, u2 = u2, u1 end loffset_save = DCL.uzpget('loffset') xyfact_save = DCL.uzpget(xy+'fact') xyoffset_save = DCL.uzpget(xy+'offset') tu1 = date_from.day_fraction.to_f range_day = date_to - date_from # time btwn start and end (in days) tu2 = tu1 + range_day # < axis in hours > DCL.uzpset('loffset',true) DCL.uzpset(xy+'fact',24.0) DCL.uzpset(xy+'offset',(tu1-u1)*24) dtick1 = opt['dtick1'] if opt['dtick2'] dtick2 = opt['dtick2'] else if range_day >= 4 dtick2 = 24 elsif range_day >= 2 dtick2 = 12 elsif range_day >= 1 dtick2 = 6 elsif range_day >= 0.5 dtick2 = 3 elsif range_day >= 0.25 dtick2 = 2 else dtick2 = 1 end end str_hour = (tu1*24).ceil end_hour = (tu2*24).floor tick1=Array.new tick2=Array.new labels=Array.new h1 = str_hour + (-str_hour % dtick1) (h1..end_hour).step(dtick1){|i| tick1.push(i)} h2 = str_hour + (-str_hour % dtick2) (h2..end_hour).step(dtick2) do |i| tick2.push(i) labels.push((i%24).to_s) end if xax DCL.uxaxlb(cside, tick1, tick2, labels, 2) else irotl_save = DCL.uzpget('irotly'+cside) icent_save = DCL.uzpget('icenty'+cside) DCL.uzpset('irotly'+cside,1) DCL.uzpset('icenty'+cside,0) DCL.uyaxlb(cside, tick1, tick2, labels, 2) end # < labels in days > if DCL.uzpget('label'+xy+cside) DCL.uzpset(xy+'fact',1.0) DCL.uzpset(xy+'offset',0.0) str_day = tu1.floor end_day = tu2.floor pos=Array.new labels=Array.new (str_day..end_day).step(1) do |i| u = i.to_f + 0.5 + (u1- tu1) u = (u1+u+0.5)/2 if u < u1 u = (u2+u-0.5)/2 if u > u2 pos.push(u) str = (date_from+i).strftime(datefmt) str.sub!(/^0/,'') if !opt['year'] && opt['month'] labels.push(str) end if xax DCL.uxsaxz(cside,DCL.uzpget('roffx'+cside)) DCL.uxplbl(cside,1,pos,labels,10) else DCL.uysaxz(cside,DCL.uzpget('roffy'+cside)) DCL.uyplbl(cside,1,pos,labels,10) # DCL.uzpset('irotly'+cside,irotl_save) # DCL.uzpset('icenty'+cside,icent_save) end end if xax else DCL.uzpset('irotly'+cside,irotl_save) DCL.uzpset('icenty'+cside,icent_save) end # < to finish > DCL.uzpset('loffset',loffset_save) DCL.uzpset(xy+'fact',xyfact_save) DCL.uzpset(xy+'offset',xyoffset_save) end |
.flow_itr5(gpx, gpy, factor = 1.0, unit_vect = false) ⇒ Object
2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 |
# File 'lib/numru/dclext.rb', line 2105 def flow_itr5( gpx, gpy, factor=1.0, unit_vect=false ) raise ArgumentError,"Expect 2D arrays" if gpx.rank != 2 || gpy.rank != 2 raise ArgumentError,"gpx.shape != gpy.shape" if gpx.shape != gpy.shape raise "Transform. No. should be 5" if DCL.sgpget('itr') != 5 theta = gpx.coord(1) / 180 * Math::PI theta = theta.reshape(1,theta.shape[0]) vx = gpx * theta.cos - gpy * theta.sin # UC component -> VC vy = gpx * theta.sin + gpy * theta.cos # UC component -> VC DCL.sglset('LCLIP',false) before1 = DCLExt.ug_set_params( {'LUNIT'=>true, 'LUMSG'=>true} ) if unit_vect before2 = DCLExt.ug_set_params( {'LNRMAL'=>false, 'XFACT1'=>factor, 'YFACT1'=>factor} ) if factor != 1.0 DCL.ugvect( vx.val, vy.val ) if unit_vect uxunit = sprintf("%.2g",DCL.ugrget('UXUNIT')) uyunit = sprintf("%.2g",DCL.ugrget('UXUNIT')) vxuloc = DCL.ugrget('VXULOC') vyuloc = DCL.ugrget('VYULOC') rsize = DCL.ugrget('RSIZET') dv = rsize DCL.sgtxzv(vxuloc, vyuloc-dv, uxunit, rsize, 0, -1, 3 ) DCL.sgtxzv(vxuloc-dv, vyuloc, uyunit, rsize, 90, -1, 3 ) end ug_set_params( before2 ) if factor != 1.0 ug_set_params( before1 ) if unit_vect end |
.flow_vect(fx, fy, factor = 1.0, xintv = 1, yintv = 1, vxfxratio = nil, vyfyratio = nil) ⇒ Object
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 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 |
# File 'lib/numru/dclext.rb', line 1865 def flow_vect( fx, fy, factor=1.0, xintv=1, =1, vxfxratio=nil, vyfyratio=nil) raise ArgumentError,"Expect 2D arrays" if fx.rank != 2 || fy.rank != 2 raise ArgumentError,"fx.shape != fy.shape" if fx.shape != fy.shape raise ArgumentError,"xintv must be a positive integer" if xintv < 0 raise ArgumentError,"yintv must be a positive integer" if < 0 nx, ny = fx.shape if xintv >= 2 idx = NArray.int(nx/xintv).indgen!*xintv # [0,xintv,2*xintv,..] fx = fx[idx, true] fy = fy[idx, true] end if >= 2 idx = NArray.int(ny/).indgen!* # [0,yintv,2*yintv,..] fx = fx[true, idx] fy = fy[true, idx] end nx, ny = fx.shape # again, because of xintv & yintv vx0,vx1,vy0,vy1 = DCL.sgqvpt wnd = DCL.sgqwnd if wnd.include?(DCL.glrget('rundef')) ux0,ux1,uy0,uy1 = DCL.sgqtxy else ux0,ux1,uy0,uy1 = wnd end dvx = (vx1-vx0)/nx dvy = (vy1-vy0)/ny ax = (vx1-vx0)/(ux1-ux0) # factor to convert from U to V coordinate ay = (vy1-vy0)/(uy1-uy0) # factor to convert from U to V coordinate fxmx = fx.abs.max fymx = fy.abs.max raise "fx has no data or all zero" if fxmx == 0 raise "fy has no data or all zero" if fymx == 0 cn = [ (dvx/(ax*fxmx)).abs, (dvy/(ay*fymx)).abs ].min # normalztn const vxfxratio = factor*cn*ax if !vxfxratio vyfyratio = factor*cn*ay if !vyfyratio before = ug_set_params( {'LNRMAL'=>false, 'LMSG'=>false, 'XFACT1'=>1.0, 'YFACT1'=>1.0} ) DCL.ugvect( vxfxratio*fx, vyfyratio*fy ) ug_set_params( before ) unit_vect_info = [ vxfxratio, vyfyratio, fxmx, fymx ] return unit_vect_info end |
.flow_vect_anyproj(fx, fy, xg, yg, factor = 1.0, xintv = 1, yintv = 1, distvect_map = true, vfratio = nil, flenmax = nil, polar_thinning = nil) ⇒ Object
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 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 2005 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 2044 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 2095 2096 2097 2098 2099 2100 2101 |
# File 'lib/numru/dclext.rb', line 1909 def flow_vect_anyproj(fx, fy, xg, yg, factor=1.0, xintv=1, =1, distvect_map=true, vfratio=nil, flenmax=nil, polar_thinning=nil) #< parameters to handle singularity of the projection > ddv = 0.3e-3 # Initial value for viewport sampling to find directions. # This parameter is modified below if the round off error # may be severe. eps = 0.05 # Allowed maximum inconsistency in two sampling results acc = 1e7 # order of mantissa of sfloat epsbk = 3e-6 # factor to judge whether a grid point is on the backside # when the projection is multi-valued as map projections #< preparation > raise ArgumentError,"Expect 2D arrays" if fx.rank != 2 || fy.rank != 2 raise ArgumentError,"fx.shape != fy.shape" if fx.shape != fy.shape raise ArgumentError,"xintv must be a positive integer" if xintv < 0 raise ArgumentError,"yintv must be a positive integer" if < 0 nx, ny = fx.shape if xg.rank == 1 raise ArgumentError,"len of xg (#{xg.length}) != #{nx}" if xg.length!=nx else raise ArgumentError,"xg.shape != shape of data" if xg.shape != fx.shape end if yg.rank == 1 raise ArgumentError,"len of yg (#{yg.length}) != #{ny}" if yg.length!=ny else raise ArgumentError,"yg.shape != shape of data" if yg.shape != fx.shape end if xintv >= 2 idx = NArray.int(nx/xintv).indgen!*xintv # [0,xintv,2*xintv,..] fx = fx[idx, true] fy = fy[idx, true] xg = xg[idx, false] end if >= 2 idx = NArray.int(ny/).indgen!* # [0,yintv,2*yintv,..] fx = fx[true, idx] fy = fy[true, idx] yg = yg[false,idx] end nx, ny = fx.shape # again, because of xintv & yintv #< read DCL parameters > index = DCL.ugpget('index') rsizem = DCL.ugpget('rsizem') itype2 = DCL.ugpget('itype2') lmissp = DCL.ugpget('lmissp') lmiss = DCL.glpget('lmiss') rmiss = DCL.glpget('rmiss') #< Missing value treatment > # -- needed to later caluculate flenmax properly if lmiss fx = NArrayMiss.to_nam(fx, fx.ne(rmiss)) if fx.is_a?(NArray) fy = NArrayMiss.to_nam(fy, fy.ne(rmiss)) if fy.is_a?(NArray) mask = fx.get_mask & fy.get_mask fx = fx.mask(mask) fy = fy.mask(mask) end #< DCL scales > wnd = DCL.sgqwnd if wnd.include?(DCL.glrget('rundef')) ux0,ux1,uy0,uy1 = DCL.sgqtxy else ux0,ux1,uy0,uy1 = wnd end flen = Misc::EMath.sqrt( fx*fx + fy*fy ) if !flenmax flenmax = flen.max end if !vfratio vx0,vx1,vy0,vy1 = DCL.sgqvpt dvf = Math::sqrt( (vx1-vx0)*(vy1-vy0)/nx/ny ) vfratio = factor * dvf / flenmax # factor to get arrow length in V crd end #< parameter modification if needed > r = [ [ux0.abs, ux1.abs].min / (ux0-ux1).abs, [uy0.abs, uy1.abs].min / (uy0-uy1).abs ].max e = acc*ddv*eps if ( r > e ) # ddv is too small for the current window, so the round off error # may be severer. --> increase it up to a prescribed limit. ddv = [ r/e*ddv, 0.1 ].min end #< handling of distance-based vectors under map projection > itr = DCL::sgqtrn map_proj = ( itr >= 10 and itr <= 40 ) if map_proj and distvect_map cosphi = Misc::EMath.cos( yg * (Math::PI/180.0) ) umodi = true else umodi = false end #< vector drawing > if map_proj uodr = 360.0 # order of domain size in U coordinate else uodr = [xg.max, -xg.min, yg.max, -yg.min].max end dbk = epsbk*uodr u = NMatrix.float(2,2) # NMatrix's index: [column,row] ap = NMatrix.float(2,2) an = NMatrix.float(2,2) for j in 0...ny if polar_thinning && xg.rank==1 && yg.rank==1 j1 = [j+1,ny-1].min dy=(yg[j1]-yg[j1-1]).abs dx = (xg[1]-xg[0]).abs * cos(yg[j]/180*Math::PI) xstep = [ (dy / dx * polar_thinning).round, 1 ].max else xstep = 1 end (0...nx).step(xstep) do |i| x = ( xg.rank==1 ? xg[i] : xg[i,j] ) y = ( yg.rank==1 ? yg[j] : yg[i,j] ) if ( ( fx.is_a?(NArrayMiss) && !fx.valid?[i,j] ) || ( fy.is_a?(NArrayMiss) && !fy.valid?[i,j] ) ) DCL.sgpmzu([x],[y],itype2,index,rsizem) if lmissp next end vx0, vy0 = DCL.stftrf(x, y) xrev, yrev = DCL.stitrf(vx0, vy0) xdif = (xrev-x).abs ydif = (yrev-y).abs xdif = 360.0-xdif if map_proj && xdif > 359.0 if xdif > dbk || ydif > dbk next # Not plotted, because the current point is on the backside end if umodi cos = ( cosphi.rank==1 ? cosphi[j] : cosphi[i,j] ) end um = NMatrix[ [x,x], [y,y] ] u[0,0],u[0,1] = DCL.stitrf(vx0+ddv, vy0) u[1,0],u[1,1] = DCL.stitrf(vx0, vy0+ddv) ap = u - um (ap[true,0] >= 180.0).where.to_a.each{|i| ap[i,0] -= 360.0} (ap[true,0] <= -180.0).where.to_a.each{|i| ap[i,0] += 360.0} u[0,0],u[0,1] = DCL.stitrf(vx0-ddv, vy0) u[1,0],u[1,1] = DCL.stitrf(vx0, vy0-ddv) an = um - u (an[true,0] >= 180.0).where.to_a.each{|i| an[i,0] -= 360.0} (an[true,0] <= -180.0).where.to_a.each{|i| an[i,0] += 360.0} if umodi ap[0,0] *= cos ap[1,0] *= cos an[0,0] *= cos an[1,0] *= cos end f = NVector[ fx[i,j],fy[i,j] ] vfp = nil begin aip = ap.inverse vfp = aip * f rescue end vfn = nil begin ain = an.inverse vfn = ain * f rescue end if vfp && vfn vf = (vfp+vfn)/2 err = (vfp - vfn).abs.max / vf.abs.max vn = vf * ( vfratio*flen[i,j] / Math.sqrt(vf[0]**2+vf[1]**2) ) if err>=eps DCL.sgpmzv([vx0],[vy0],itype2,index,rsizem) if lmissp elsif vn[0].nan? || vn[1].nan? DCL.sgpmzv([vx0],[vy0],itype2,index,rsizem) else DCL.sglazv(vx0, vy0, vx0+vn[0], vy0+vn[1], 1, index) end end end end [ vfratio, flenmax ] end |
.get_proj_params ⇒ Object
2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 |
# File 'lib/numru/dclext.rb', line 2255 def get_proj_params { :itr => DCL::sgqtrn, :vpt => DCL::sgqvpt, :wnd => DCL::sgqwnd, :sim => DCL::sgqsim, :cnt => DCL::umqcnt, :lglobe => DCL::umpget('lglobe'), :rsat => DCL::sgpget("rsat"), :txy => %w(txmin txmax tymin tymax).map{|key| DCL::sgrget(key)} } end |
.lat_ax(options = nil) ⇒ Object
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 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 |
# File 'lib/numru/dclext.rb', line 1638 def lat_ax(=nil) opt = @@lat_ax_options.interpret() xax = opt['xax'] yax = !xax xy = (xax ? 'x' : 'y') cside = opt['cside'] cside = (xax ? 'b' : 'l') if cside.nil? cside ||= (xax ? 't' : 'r') ### cside is false vxmin, vxmax, vymin, vymax = DCL.sgqvpt uxmin, uxmax, uymin, uymax = DCL.sgqwnd if xax vmin, vmax = [vxmin,vxmax].min, [vxmin,vxmax].max umin, umax = [uxmin,uxmax].min, [uxmin,uxmax].max else vmin, vmax = [vymin,vymax].min, [vymin,vymax].max umin, umax = [uymin,uymax].min, [uymin,uymax].max end # get dtick1 & dtick2 dtick1 = opt['dtick1'] dtick2 = opt['dtick2'] unless dtick1 && dtick2 irota = DCL.uzpget("irotl#{xy}#{cside}") irota += 1 if yax mode = irota.modulo(2) DCL.ususcu(xy.capitalize,umin,umax,vmin,vmax,mode) dtick1 = DCL.uspget("d#{xy}t") unless dtick1 dtick2 = DCL.uspget("d#{xy}l") unless dtick2 end lepsl = DCL.glpget('lepsl') repsl = DCL.glpget('repsl') DCL.glpset('lepsl',true) # generate numbers for small tickmarks nn = 0 x = DCL.irle(umin / dtick1) * dtick1 x += dtick1 unless DCL.lreq(umin, x) u1 = [] while DCL.lrle(x,umax) if x.abs < dtick1*repsl*nn x = 0.0 end u1[nn] = x nn += 1 x += dtick1 end # generate numbers for large tickmarks and labels nn = 0 x = DCL.irle(umin / dtick2) * dtick2 x += dtick2 unless DCL.lreq(umin, x) u2 = [] while DCL.lrle(x,umax) if x.abs < dtick2*repsl*nn x = 0 end u2[nn] = x nn += 1 x += dtick2 end # generate labels c2 = NArray.to_na(u2) c2 = c2.to_a.collect do |c| if c == 0 'EQ' elsif c > 0 c.to_i.to_s + 'N' else c.abs.to_i.to_s + 'S' end end nc = c2.collect{|c| c.size}.max # call DCL.u[xy]axlb DCL.__send__(xax ? :uxaxlb : :uyaxlb , cside, u1, u2, c2, nc) DCL.glpset('lepsl', lepsl) # restore original value end |
.legend(str, type, index, line = false, size = nil, vx = nil, dx = nil, vy = nil, first = true, mark_size = nil) ⇒ Object
Annotates line/mark type and index (and size if mark). By default it is shown in the right margin of the viewport.
-
str is a String to show
-
line: true->line ; false->mark
-
vx: vx of the left-hand point of legend line (or mark position).
* nil : internally determined * Float && > 0 : set explicitly * Float && < 0 : move it relatively to the left from the default
-
dx: length of the legend line (not used if mark).
* nil : internally determined * Float && > 0 : set explicitly
-
vy: vy of the legend (not used if !first – see below).
* nil : internally determined * Float && > 0 : set explicitly * Float && < 0 : move it relatively lower from the default
-
first : if false, vy is moved lower relatively from the previous vy.
-
mark_size : size of the mark. if nil, size is used.
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 |
# File 'lib/numru/dclext.rb', line 2874 def legend(str, type, index, line=false, size=nil, vx=nil, dx=nil, vy=nil, first=true, mark_size=nil) size ||= DCL::uzrget("rsizel1") * 0.95 mark_size ||= size vpx1,vpx2,vpy1,vpy2 = DCL.sgqvpt if first || (!@vy) vy ||= vpy2 - 0.04 vy += vpy2 - 0.04 if vy < 0 else vy ||= @vy - 1.5 * size end @vy = vy vx ||= vpx2 + 0.015 vx = (vpx2 + 0.015) + vx if vx < 0 if line dx ||= 0.06 vx2 = vx + dx DCL::sgplzv([vx,vx2],[vy,vy],type,index) DCL.sgtxzv(vx2+0.01,vy,str,size,0,-1,3) else # --> mark DCL::sgpmzv([vx],[vy],type,index,mark_size) DCL.sgtxzv(vx+0.015+mark_size*0.5,vy,str,size,0,-1,3) end nil end |
.level_chval_fmt(max, min, dx) ⇒ Object
2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 |
# File 'lib/numru/dclext.rb', line 2187 def level_chval_fmt(max,min,dx) # returns a format for DCL.chval suitable for color-bar labels dxabs = dx.abs eps = 1e-4 * dxabs order = log10_or_0(dxabs).floor if ( (dxabs+eps*0.1) % 10**order < eps ) # 1 keta least_order = order else # >=2 keta --> limit to 2 keta least_order = order - 1 end ng = log10_or_0([max.abs,min.abs,eps].max).floor - least_order + 1 if ng <= 3 fmt = 'b' else n = log10_or_0([max.abs,min.abs].max).floor nn = log10_or_0([max.abs,min.abs].min).floor if least_order >= 0 and nn >= 0 ifg = 'i' elsif 0 <= n and n <= 4 ifg = 'f' else ifg = 'g' end case(ifg) when 'i' fmt = '(i15)' when 'g' ng = log10_or_0([max.abs,min.abs,eps].max).floor - least_order + 1 ng = [ ng, 2 ].max fmt = "(g15.#{ng})" when 'f' nf = [ -least_order, 0].max fmt = "(f15.#{nf})" end end fmt end |
.log10_or_0(val) ⇒ Object
2183 2184 2185 |
# File 'lib/numru/dclext.rb', line 2183 def log10_or_0(val) log10_safe(val) || 0 end |
.log10_safe(val) ⇒ Object
2175 2176 2177 2178 2179 2180 2181 |
# File 'lib/numru/dclext.rb', line 2175 def log10_safe(val) begin Math::log10(val) rescue Errno::ERANGE nil end end |
.lon_ax(options = nil) ⇒ Object
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 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
# File 'lib/numru/dclext.rb', line 1544 def lon_ax(=nil) opt = @@lon_ax_options.interpret() yax = opt['yax'] xax = !yax xy = (xax ? 'x' : 'y') cside = opt['cside'] cside = (xax ? 'b' : 'l') if cside.nil? cside ||= (xax ? 't' : 'r') ### cside is false vxmin, vxmax, vymin, vymax = DCL.sgqvpt uxmin, uxmax, uymin, uymax = DCL.sgqwnd if xax vmin, vmax = [vxmin,vxmax].min, [vxmin,vxmax].max umin, umax = [uxmin,uxmax].min, [uxmin,uxmax].max else vmin, vmax = [vymin,vymax].min, [vymin,vymax].max umin, umax = [uymin,uymax].min, [uymin,uymax].max end # get dtick1 & dtick2 dtick1 = opt['dtick1'] dtick2 = opt['dtick2'] unless dtick1 && dtick2 irota = DCL.uzpget("irotl#{xy}#{cside}") irota += 1 if yax mode = irota.modulo(2) DCL.ususcu(xy.capitalize,umin,umax,vmin,vmax,mode) dtick1 = DCL.uspget("d#{xy}t") unless dtick1 dtick2 = DCL.uspget("d#{xy}l") unless dtick2 end lepsl = DCL.glpget('lepsl') repsl = DCL.glpget('repsl') DCL.glpset('lepsl',true) # generate numbers for small tickmarks nn = 0 x = DCL.irle(umin / dtick1) * dtick1 x += dtick1 unless DCL.lreq(umin, x) u1 = [] while DCL.lrle(x,umax) if x.abs < dtick1*repsl*nn x = 0.0 end u1[nn] = x nn += 1 x += dtick1 end # generate numbers for large tickmarks and labels nn = 0 x = DCL.irle(umin / dtick2) * dtick2 x += dtick2 unless DCL.lreq(umin, x) u2 = [] while DCL.lrle(x,umax) if x.abs < dtick2*repsl*nn x = 0 end u2[nn] = x nn += 1 x += dtick2 end # generate labels c2 = NArray.to_na(u2) c2[c2.gt(180)] -= 360.0 c2[c2.lt(-180)] += 360.0 c2[c2.eq(-180)] = 180.0 c2 = c2.to_a.collect do |c| if c == 0 || c == 180 c.to_i.to_s elsif c > 0 c.to_i.to_s + 'E' else c.abs.to_i.to_s + 'W' end end nc = c2.collect{|c| c.size}.max # call DCL.u[xy]axlb DCL.__send__(xax ? :uxaxlb : :uyaxlb , cside, u1, u2, c2, nc) DCL.glpset('lepsl', lepsl) # restore original value end |
.next_ui_shade_1_options(options) ⇒ Object
1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'lib/numru/dclext.rb', line 1059 def () if .is_a?(Hash) @@next_ui_shade_1_options = else raise TypeError,"Hash expected" end nil end |
.next_unit_vect_options(options) ⇒ Object
1750 1751 1752 1753 1754 1755 1756 1757 |
# File 'lib/numru/dclext.rb', line 1750 def () if .is_a?(Hash) @@next_unit_vect_options = else raise TypeError,"Hash expected" end nil end |
.quasi_log_levels(lev0, lev1, cycle = 1) ⇒ Object
Returns approximately log-scaled contour/tone levels as well as major/minor flags for contours. No DCL call is made in here.
-
cycle (Integer; 1, or 2 or 3) : number of level in one-order. e.g. 1,10,100,.. for cycle==1; 1,3,10,30,.. for cycle==2; 1,2,5,10,20,50,.. for cycle==3
-
lev0, lev1 (Float) : levels are set between this two params
-
if lev0 & lev1 > 0 : positive only
-
if lev0 & lev1 < 0 : negative only
-
if lev0 * lev1 < 0 : both positive and negative (usig +-[lev0.abs,lev1.abs])
-
RETURN VALUE:
- levels, mjmn
2955 2956 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 3004 3005 3006 3007 3008 3009 3010 3011 |
# File 'lib/numru/dclext.rb', line 2955 def quasi_log_levels(lev0, lev1, cycle=1) raise(ArgumentError, "lev0 is zero (non-zero required)") if lev0 == 0.0 raise(ArgumentError, "lev1 is zero (non-zero required)") if lev1 == 0.0 case cycle when 1 cycl_levs = [1.0] when 2 cycl_levs = [1.0, 3.0] when 3 cycl_levs = [1.0, 2.0, 5.0] else raise(ArgumentError, "cycle must be 1,2,or 3, which is now #{cycle}") end if lev0 > 0 and lev1 > 0 positive = true negative = false elsif lev0 < 0 and lev1 < 0 positive = false negative = true else positive = true negative = true end sml, big = [lev0.abs,lev1.abs].sort expsml = Math::log10(sml).floor expbig = Math::log10(big).ceil levels = Array.new mjmn = Array.new for i in expsml..expbig-1 for k in 0..cycle-1 lev = cycl_levs[k] * 10**i if lev >= sml && lev <= big levels.push( lev ) mjmn.push( k==0 ? 1 : 0 ) end end end lev = 10**expbig if lev == big levels.push( lev ) mjmn.push( 1 ) end if negative && !positive levels = levels.reverse.collect{|x| -x} mjmn = mjmn.reverse elsif negative && positive levels.dup.each{|x| levels.unshift(-x)} mjmn.dup.each{|x| mjmn.unshift(x)} end [ levels, mjmn ] end |
.quasi_log_levels_z(vals, nlev = nil, max = nil, min = nil, cycle = 1) ⇒ Object
Driver of quasi_log_levels with data values
2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 |
# File 'lib/numru/dclext.rb', line 2905 def quasi_log_levels_z(vals, nlev=nil, max=nil, min=nil, cycle=1) if max && min quasi_log_levels(max.to_f, min.to_f, cycle) else if nlev eps = 0.1 norder = (nlev-1.0+eps)/cycle else norder = 3 end mx1 = vals.max mx2 = vals.min if min && min < 0 max = min min = nil elsif max && max < 0 min = max max = nil end maxsv = max minsv = min if !max max = [ mx1.abs, mx2.abs ].max.to_f max = -max if mx1<0 end if !min min = max/10**norder else max = min*10**norder if nlev end if !(minsv && minsv>0) && !(maxsv && maxsv <0) && ( mx2<0 && mx1>0 ) min = -min end quasi_log_levels(max, min, cycle) end end |
.restore_proj_params(hash) ⇒ Object
hash: OUTPUT OF DCLExt::get_proj_params
2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 |
# File 'lib/numru/dclext.rb', line 2266 def restore_proj_params(hash) # hash: OUTPUT OF DCLExt::get_proj_params DCL::grsvpt(*(hash[:vpt])) DCL::grswnd(*(hash[:wnd])) if hash[:itr] <= 4 DCL::grstrn(hash[:itr]) elsif hash[:itr] <= 9 DCL::sgssim(*(hash[:sim])) DCL::grstrn(hash[:itr]) elsif hash[:itr] <= 34 DCL::sgstrn(hash[:itr]) DCL::umpset("lglobe", hash[:lglobe]) DCL::grstxy(*(hash[:txy])) DCL::umscnt(*(hash[:cnt])) DCL::sgpset("rsat", hash[:rsat]) DCL::umpfit DCL::sgssim(*(hash[:sim])) end DCL::grstrf end |
.set_color_bar_options(options) ⇒ Object
2171 2172 2173 |
# File 'lib/numru/dclext.rb', line 2171 def () @@color_bar_options.set() end |
.set_ui_shade_1_options(options) ⇒ Object
1054 1055 1056 |
# File 'lib/numru/dclext.rb', line 1054 def () @@ui_shade_1_options.set() end |
.set_unit_vect_options(options) ⇒ Object
1745 1746 1747 |
# File 'lib/numru/dclext.rb', line 1745 def () @@unit_vect_options.set() end |
.shade_1_option_keys ⇒ Object
1050 1051 1052 |
# File 'lib/numru/dclext.rb', line 1050 def shade_1_option_keys @@ui_shade_1_options.keys end |
.sht_get_m(mm) ⇒ Object
calcurate m (zonal wavenum)
714 715 716 717 718 719 720 721 722 723 724 |
# File 'lib/numru/dclext.rb', line 714 def sht_get_m(mm) ns = NArray.int((mm+1)**2) i = mm+1 for m in 1..mm ns[i..(i+mm-m)] = m i += mm-m+1 ns[i..(i+mm-m)] = m i += mm-m+1 end ns end |
.sht_get_n(mm) ⇒ Object
calcurate n (total wavenum)
699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/numru/dclext.rb', line 699 def sht_get_n(mm) ns = NArray.int((mm+1)**2) mi = NArray.int(mm+1).indgen! ns[0..mm] = mi # for m=0 i = mm+1 for m in 1..mm ns[i..(i+mm-m)] = mi[m..mm] i += mm-m+1 ns[i..(i+mm-m)] = mi[m..mm] i += mm-m+1 end ns end |
.sprintf_level(x, max, min, dx) ⇒ Object
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 |
# File 'lib/numru/dclext.rb', line 2227 def sprintf_level(x,max,min,dx) # format a float for color-bar labels. # like DCL.hval('b',x) but changes according to dx if x==0 fg = 'f' else n = log10_or_0(x.abs).floor fg = ((0 <= n) && (n <= 4)) ? 'f' : 'g' end eps = 1e-6 if ( dx.abs % 10**log10_or_0(dx.abs) < eps ) # 1 keta least_order = log10_or_0(dx.abs).floor else # >=2 keta --> limit to 2 keta least_order = log10_or_0(dx.abs).floor - 1 end if fg == 'g' ng = log10_or_0([max.abs,min.abs,eps].max).floor - least_order + 1 ng = [ ng, 2 ].max fmt = "%.#{ng}g" else nf = [ -least_order, 0].max fmt = "%.#{nf}f" end sprintf(fmt,x).sub(/\.0*$/,'') end |
.ud_add_contour(levels, index = nil, line_type = nil, label = nil, label_height = nil) ⇒ Object
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
# File 'lib/numru/dclext.rb', line 791 def ud_add_contour(levels,index=nil,line_type=nil,label=nil,label_height=nil) # < check levels > case levels when Array, NArray # This is expected. Nothing to do. when Numric levels = [levels] else raise ArgumentError, "invalid level specification (#{levels})" end nlev = levels.length # < index > index = index.to_a if index.is_a?(NArray) case index when Array raise ArgumentError, "index is an empty array" if index.length == 0 while (index.length < nlev ) index += index end when Numeric index = [index]*nlev when nil index = [DCL.udpget('indxmn')]*nlev else raise ArgumentError, "unsupported index type (#{index.class})" end # < line_type > line_type = line_type.to_a if line_type.is_a?(NArray) case line_type when Array raise ArgumentError, "line_type is an empty array" if line_type.length == 0 while (line_type.length < nlev ) line_type += line_type end when Numeric line_type = [line_type]*nlev when nil line_type = [1]*nlev else raise ArgumentError, "unsupported index type (#{index.class})" end # < label > label = label.to_a if label.is_a?(NArray) case label when Array raise ArgumentError, "label is an empty array" if label.length == 0 while (label.length < nlev ) label += label end when String label = [label]*nlev when false label = [""]*nlev when true label = (0...nlev).collect{|i| DCL.udlabl(levels[i]) } when nil indxmj = DCL.udpget('indxmj') label = (0...nlev).collect{|i| if index[i]==indxmj DCL.udlabl(levels[i]) else "" end } else raise ArgumentError, "unsupported index type (#{index.class})" end # < label_height > label_height = label_height.to_a if label_height.is_a?(NArray) case label_height when Array raise ArgumentError, "label_height is an empty array" if label_height.length == 0 while (label_height.length < nlev ) label_height += label_height end when Numeric label_height = [label_height]*nlev when nil label_height = label.collect{|lv| lv=="" ? 0.0 : DCL.udpget('rsizel')} else raise ArgumentError, "unsupported index type (#{index.class})" end # < set levels > for i in 0...nlev DCL.udsclv(levels[i],index[i],line_type[i],label[i],label_height[i]) end nil end |
.ud_coloring(clr_min = 13, clr_max = 99) ⇒ Object
<<< udpack >>>
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
# File 'lib/numru/dclext.rb', line 728 def ud_coloring(clr_min=13, clr_max=99) # change the colors of existing contours to make a gradation # (rainbow colors with the default color map). nlev = DCL.udqcln cont_params = Array.new for i in 1..nlev cont_params.push( DCL.udqclv(i) ) # => [zlev,indx,ityp,clv,hl] end DCL.udiclv # clear the contours colors = clr_min + NArray.int(nlev).indgen! * (clr_max-clr_min) / nlev cont_params.sort! for i in 0...nlev cont_params[i][1] += colors[i]*10 # indx += colors[i]*10 DCL.udsclv(*cont_params[i]) end end |
.ud_set_contour(*args) ⇒ Object
786 787 788 789 |
# File 'lib/numru/dclext.rb', line 786 def ud_set_contour(*args) DCL.udiclv ud_add_contour(*args) end |
.ud_set_linear_levs(v, options = nil) ⇒ Object
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 |
# File 'lib/numru/dclext.rb', line 748 def ud_set_linear_levs(v, =nil) #Accepted options # name default description # 'min' nil minimum contour value (Numeric) # 'max' nil maximum contour value (Numeric) # 'nlev' nil number of levels (Integer) # 'interval' nil contour interval (Numeric) # 'nozero' false delete zero contour (true/false) # 'coloring' false set color contours with ud_coloring (true/false) # 'clr_min' 13 (if coloring) minimum color number for the # maximum data values (Integer) # 'clr_max' 99 (if coloring) maximum color number for the # maximum data values (Integer) ||= @@empty_hash raise TypeError, "options must be a Hash" if !.is_a?(Hash) min = ['min'] max = ['max'] nlev = ['nlev'] interval = ['interval'] nozero = ['nozero'] dx = interval || (nlev ? -nlev : 0) if min || max min ||= v.min max ||= v.max DCL.udgcla(min, max, dx) else DCL.udgclb(v, dx) end if nozero DCL.uddclv(0.0) end if ['coloring'] clr_min = ( ['clr_min'] || 13 ) clr_max = ( ['clr_max'] || 99 ) ud_coloring( clr_min, clr_max ) end end |
.ue_add_tone(levels, patterns) ⇒ Object
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File 'lib/numru/dclext.rb', line 998 def ue_add_tone(levels, patterns) # < check types > if !levels.is_a?(Array) && !levels.is_a?(NArray) raise TypeError, "levels: Array or NArray expected (#{levels.inspect})" end if !patterns.is_a?(Array) && !patterns.is_a?(NArray) raise TypeError, "patterns: Array or NArray expected (#{patterns.inspect})" end # < set levels > nlev = levels.length npat = patterns.length case (nlev - npat) when 1 for i in 0...nlev-1 DCL.uestlv(levels[i],levels[i+1],patterns[i]) end when 0 for i in 0...nlev-1 DCL.uestlv(levels[i],levels[i+1],patterns[i]) end DCL.uestlv(levels[-1],DCL.glpget('rmiss'),patterns[-1]) when -1 DCL.uestlv(DCL.glpget('rmiss'),levels[0],patterns[0]) for i in 1...nlev DCL.uestlv(levels[i-1],levels[i],patterns[i]) end DCL.uestlv(levels[-1],DCL.glpget('rmiss'),patterns[-1]) else raise ArgumentError, "lengths of levels(#{nlev}) and patterns(#{npat}) are inconsistent" end nil end |
.ue_linear_levels(min, max, dx, lbound = false, inf_min = false, inf_max = false) ⇒ Object
Same as level setting in uegtla but supporting extension to infinity
-
inf_min false: no extension, true: extend to -infty, nil: same but for min is replaced by -infty, rather than extending
-
inf_max false: no extension, true: extend to infty, nil: same but for max is replaced by infty, rather than extending
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
# File 'lib/numru/dclext.rb', line 929 def ue_linear_levels(min, max, dx, lbound=false, inf_min=false, inf_max=false) if !min || ( min.is_a?(Float) && min.nan? )|| !max || ( max.is_a?(Float) && max.nan? ) return [0.0] end if dx > 0 dz = dx.to_f else nlev = ( dx==0 ? DCL.ueiget('nlev') : [dx.abs.round, 1].max ) dz = DCL.rgnge( (max-min)/nlev.to_f ) end if dz != 0 zmin = DCL.irle(min/dz)*dz zmax = DCL.irge(max/dz)*dz n = ((zmax-zmin)/dz).round else zmin = min n = 0 end levels = [ zmin ] for i in 1..n x = ((zmin+i*dz)/dz).round * dz levels.push(x) end if lbound levels[0] = [ levels[0], min ].max levels[-1] = [ levels[-1], max ].min end rmiss = DCL.glpget("rmiss") if inf_min levels.unshift(rmiss) # extension elsif inf_min.nil? levels[0] = rmiss # in-place substitusion end if inf_max levels.push(rmiss) # extension elsif inf_max.nil? levels[-1] = rmiss # in-place substitusion end levels end |
.ue_set_linear_levs(v, options = nil) ⇒ Object
options:
'min' Numeric minimum tone level
'max' Numeric maximum tone level
'nlev' Integer number of levels
'interval' Numeric tone-level interval
'inf_max' true/false to set (or not) the maximum tone level to infty
'inf_min' true/false to set (or not) the minimum tone level to infty
'lbound' true/false Same as uepack param LBOUND but default is false
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
# File 'lib/numru/dclext.rb', line 901 def ue_set_linear_levs(v, =nil) = @@empty_hash if ! raise TypeError, "options must be a Hash" if !.is_a?(Hash) min = ['min'] max = ['max'] nlev = ['nlev'] interval = ['interval'] dx = interval || (nlev ? -nlev : 0) inf_min = ['inf_min'] inf_min = false if inf_min.nil? inf_min = nil if inf_min && !min # for in-place substitution inf_max = ['inf_max'] inf_max = false if inf_max.nil? inf_max = nil if inf_max && !max # for in-place substitution lbound = ['lbound'] min ||= v.min max ||= v.max levels = ue_linear_levels(min, max, dx, lbound, inf_min, inf_max) ue_set_tone_auto(levels) end |
.ue_set_tone(levels, patterns) ⇒ Object
993 994 995 996 |
# File 'lib/numru/dclext.rb', line 993 def ue_set_tone(levels, patterns) DCL.ueitlv ue_add_tone(levels, patterns) end |
.ue_set_tone_auto(levels) ⇒ Object
similar to uegtla/uegtlb but for levels are given
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
# File 'lib/numru/dclext.rb', line 977 def ue_set_tone_auto(levels) DCL.ueitlv nlev = levels.length-1 itpat = DCL.ueiget('ITPAT') iclr1 = DCL.ueiget('ICOLOR1') iclr2 = DCL.ueiget('ICOLOR2') (0...nlev).each do |i| if nlev==1 ipat = (iclr2-iclr1)/2*1000+itpat else ipat = ((iclr2-iclr1)/(nlev-1.0)*i+iclr1).round*1000 + itpat end DCL.uestlv(levels[i], levels[i+1],ipat) end end |
.ui_color_bar_1(options = nil) ⇒ Object
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 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 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
# File 'lib/numru/dclext.rb', line 1113 def (=nil) raise("ui_shade_1 has not been called") if !@@ui_shade_1_called # < set parameters > opt = @@ui_color_bar_1_options.interpret() # to be replaced landscape = opt["landscape"] || !opt["portrait"] portrait = !landscape max = @@ui_shade_1_max min = @@ui_shade_1_min # < calc position > vwidth = opt["vwidth"] vlength = opt["vlength"] vx1, vx2, vy1, vy2 = DCL.sgqvpt if portrait if !opt["left"] # right voff = opt["voff"] || DCL.uzrget('roffyr') + DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vxmin = vx2 + voff vxmax = vx2 + voff + vwidth axside = "r" else # left voff = opt["voff"] ? -opt["voff"] : \ DCL.uzrget('roffyl') - DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vxmax = vx1 + voff vxmin = vx1 + voff - vwidth axside = "l" end vymin =( opt["vcent"] ? opt["vcent"]-vlength/2 : vy1 ) vymax =( opt["vcent"] ? opt["vcent"]+vlength/2 : vy1+vlength ) else ## landscape ## vxmin = (opt["vcent"] || ((vx1 + vx2) / 2)) - vlength / 2 vxmax = (opt["vcent"] || ((vx1 + vx2) / 2)) + vlength / 2 if opt["top"] # top voff = opt["voff"] || DCL.uzrget('roffxt') + DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vymin = vy2 + voff vymax = vy2 + voff + vwidth axside = "t" else # bottom voff = opt["voff"] ? -opt["voff"] : \ DCL.uzrget('roffxb') - DCL.uzrget('pad1')*DCL::uzrget("rsizec2") vymax = vy1 + voff vymin = vy1 + voff - vwidth axside = "b" end end # apply optional parameters for axes and labels index = opt["index"] || DCL::uziget("indext2") index = 1 if index <= 0 charindex = opt["charindex"] || DCL::uziget("indexl1") charindex = 1 if charindex <= 0 charfact = opt["charfact"] charfact = 1 if charfact < 0 rsizel1 = charfact * DCL::uzrget("rsizel1") axparam_bk = DCLExt.uz_set_params( "indext1" => index, "indext2" => index, "indexl1" => charindex, "rsizel1" => rsizel1, "rsizet1" => vwidth*0.25, "rsizet2" => vwidth*0.4, 'labelyl' => axside=="l", 'labelyr' => axside=="r", 'labelxb' => axside=="b", 'labelxt' => axside=="t", 'icentyr' => ((voff > 0) ? -1.0 : 1.0) ) if portrait cbwindow = [0.0, 1.0, min, max] else cbwindow = [min, max, 0.0, 1.0] end DCL.grfig DCL.grsvpt(vxmin,vxmax,vymin,vymax) DCL.grswnd(*cbwindow) DCL.grstrn(1) DCL.grstrf if portrait z = NArray.to_na( [ [min,min], [max,max] ] ) else z = NArray.to_na( [ [min,max], [min,max] ] ) end #DCL.uiscsq(@@ui_shade_1_rgbs, @@ui_shade_1_levs) #DCL.uiscrg(min,max) DCL.uwsgxb(cbwindow[0], cbwindow[1], 2) DCL.uwsgyb(cbwindow[2], cbwindow[3], 2) DCL.uipdat(z) fmt = opt['chval_fmt'] inf0 = @@ui_shade_1_min_given inf1 = @@ui_shade_1_max_given if portrait # draw frame, tick lines, and labels if fmt cfmt_bk = DCL::uyqfmt #DCL::uysfmt(fmt) DCL::uspset('cyfmt',fmt) end DCL::usyaxs(axside) if axside=="l" DCL.sglnzv(vxmax,vymin,vxmax,vymax,3) else DCL.sglnzv(vxmin,vymin,vxmin,vymax,3) end DCL::uxaxdv("b",1,index) if !inf0 DCL::uxaxdv("t",1,index) if !inf1 #DCL::uysfmt(cfmt_bk) if fmt DCL::uspset('cyfmt',cfmt_bk) if fmt else ## landscape ## # draw frame, tick lines, and labels if fmt cfmt_bk = DCL::uxqfmt #DCL::uxsfmt(fmt) DCL::uspset('cxfmt',fmt) end DCL::usxaxs(axside) if axside=="b" DCL.sglnzv(vxmin,vymax,vxmax,vymax,3) else DCL.sglnzv(vxmin,vymin,vxmax,vymin,3) end DCL::uyaxdv("l",1,index) if !inf0 DCL::uyaxdv("r",1,index) if !inf1 #DCL::uxsfmt(cfmt_bk) if fmt DCL::uspset('cxfmt',cfmt_bk) if fmt end DCLExt.(vxmin, vxmax, vymin, vymax, portrait, voff, opt['title'], opt['units'], opt['title_voff'], opt['units_voff']) inffact = opt["inffact"] if inf0 DCLExt.(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, -1, @@ui_shade_1_rgbs[0], index) end if inf1 DCLExt.(vxmin, vxmax, vymin, vymax, vwidth, portrait, inffact, 1, @@ui_shade_1_rgbs[-1], index) end DCLExt.uz_set_params(axparam_bk) DCL.uwsgxz(false) DCL.uwsgyz(false) end |
.ui_shade_1(z, options = nil) ⇒ Object
A wrapper of UIPDAT supporting options.
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
# File 'lib/numru/dclext.rb', line 1071 def ui_shade_1(z, =nil) if @@next_ui_shade_1_options = ( ? @@next_ui_shade_1_options.update() : @@next_ui_shade_1_options ) @@next_ui_shade_1_options = nil end opt = @@ui_shade_1_options.interpret() @@ui_shade_1_called = true @@ui_shade_1_min_given = !opt["min"].nil? @@ui_shade_1_max_given = !opt["max"].nil? @@ui_shade_1_min = min = opt["min"] || z.min @@ui_shade_1_max = max = opt["max"] || z.max @@ui_shade_1_rgbs = rgbs = ( opt["rgb"] || Default_RGB_1D ) nrgbs = rgbs.length @@ui_shade_1_levs = levs = opt["place_rgb"] || NArray.float(nrgbs).indgen! raise("Length missmatch: 'rgb' & 'place_rgb'") if levs.length != nrgbs DCL.uiscsq(levs,rgbs) DCL.uiscrg(min,max) DCL.uipdat(z) end |
.unit_vect(vxfxratio, vyfyratio, fxunit = nil, fyunit = nil, options = nil) ⇒ Object
(V cood length)/(actual length) in x
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 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 |
# File 'lib/numru/dclext.rb', line 1759 def unit_vect( vxfxratio, # (V cood length)/(actual length) in x vyfyratio, # (V cood length)/(actual length) in y fxunit=nil, # If specified, x unit vect len fyunit=nil, # If specified, y unit vect len =nil ) #< options > if @@next_unit_vect_options = ( ? @@next_unit_vect_options.update() : @@next_unit_vect_options ) @@next_unit_vect_options = nil end opt = @@unit_vect_options.interpret() vxunit = opt['vxunit'] vyunit = opt['vyunit'] vxuloc = opt['vxuloc'] vyuloc = opt['vyuloc'] rsizet = opt['rsizet'] index = opt['index'] #< unit vector > if fxunit vxunit = (vxfxratio * fxunit).abs else fxunit = vxunit / vxfxratio end if fyunit vyunit = (vyfyratio * fyunit).abs else fyunit = vyunit / vyfyratio end if fxunit != 0 fxunit = __truncate( (uxusv=fxunit) ) vxunit = vxunit * (fxunit/uxusv) end if fyunit != 0 fyunit = __truncate( (uyusv=fyunit) ) vyunit = vyunit * (fyunit/uyusv) end if !(vxuloc && vyuloc) vx0,vx1,vy0,vy1 = DCL.sgqvpt vxuloc = vx1 + opt['vxuoff'] if !vxuloc vyuloc = vy0 + opt['vyuoff'] if !vyuloc end DCL.sglazv( vxuloc, vyuloc, vxuloc+vxunit, vyuloc, 1, index ) DCL.sglazv( vxuloc, vyuloc, vxuloc, vyuloc+vyunit, 1, index ) #< labelling > sfxunit = sprintf("%.2g",fxunit) sfyunit = sprintf("%.2g",fyunit) rsizet = DCL.uzpget('rsizel1') if !rsizet if opt['inplace'] if vxunit != 0 DCL.sgtxzv(vxuloc, vyuloc-1.2*rsizet, sfxunit, rsizet, 0, -1, index) end if vyunit != 0 DCL.sgtxzv(vxuloc+1.2*rsizet, vyuloc+0.5*rsizet, sfyunit, rsizet, 90, -1, index) end else msg= "UNIT VECTOR X:#{sfxunit} Y:#{sfyunit}" before = uz_set_params({'rsizec1'=>rsizet}) DCL.uxsttl('b',' ',0.0) DCL.uxsttl('b',msg,0.0) uz_set_params(before) end end |
.unit_vect_single(vfratio, flen, options = nil) ⇒ Object
1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 |
# File 'lib/numru/dclext.rb', line 1827 def unit_vect_single(vfratio, flen, =nil ) #< options > if @@next_unit_vect_options = ( ? @@next_unit_vect_options.update() : @@next_unit_vect_options ) @@next_unit_vect_options = nil end opt = @@unit_vect_options.interpret() vxuloc = opt['vxuloc'] vyuloc = opt['vyuloc'] rsizet = opt['rsizet'] || DCL.uzpget('rsizel1') index = opt['index'] vertical = opt['vertical'] #< show the unit vector and the label > if !(vxuloc && vyuloc) vx0,vx1,vy0,vy1 = DCL.sgqvpt vxuloc = vx1 + opt['vxuoff'] if !vxuloc vyuloc = vy0 + opt['vyuoff'] if !vyuloc end vlen = vfratio * flen label = DCL.chval("B",flen) lclip_bk = DCLExt.sg_set_params("lclip" => false) if vertical DCL.sglazv( vxuloc, vyuloc, vxuloc, vyuloc+vlen, 1, index ) DCL.sgtxzv( vxuloc+1.2*rsizet, vyuloc+0.4*vlen, label, rsizet, 90, 0, index) else DCL.sglazv( vxuloc, vyuloc, vxuloc+vlen, vyuloc, 1, index ) DCL.sgtxzv( vxuloc+0.4*vlen, vyuloc-1.2*rsizet, label, rsizet, 0, 0, index) end DCLExt.sg_set_params(lclip_bk) nil end |
.year_ax(xax, cside, date_from, date_to) ⇒ Object
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
# File 'lib/numru/dclext.rb', line 1511 def year_ax(xax, cside, date_from, date_to) y0 = date_from.year d0 = date_from.yday ry0 = y0 + ( date_from.leap? ? d0/366.0 : d0 / 365.0 ) y1 = date_to.year d1 = date_to.yday ry1 = y1 + ( date_to.leap? ? d1/366.0 : d1 / 365.0 ) if xax DCL.uzpset("xoffset",ry0) ux0,ux1, = DCL.sgqwnd DCL.uzpset("xfact",(ry1-ry0)/(ux1-ux0)) DCL.usxaxs(cside) DCL.uzpset("xoffset",0.0) DCL.uzpset("xfact",1.0) else DCL.uzpset("yoffset",ry0) ux0,ux1,uy0,uy1 = DCL.sgqwnd DCL.uzpset("yfact",(ry1-ry0)/(uy1-uy0)) DCL.usyaxs(cside) DCL.uzpset("yoffset",0.0) DCL.uzpset("yfact",1.0) end end |