Class: NumRu::GPhys::Grib::GribPDS
- Inherits:
-
Object
- Object
- NumRu::GPhys::Grib::GribPDS
- Includes:
- NumRu::GPhys::GribUtils
- Defined in:
- lib/numru/gphys/grib.rb
Overview
end definition of class GribIS
Instance Method Summary collapse
- #ave ⇒ Object
- #bms? ⇒ Boolean
- #center ⇒ Object
- #date ⇒ Object
- #dfact ⇒ Object
- #gds? ⇒ Boolean
- #get ⇒ Object
- #gid ⇒ Object
- #initial ⇒ Object
- #length ⇒ Object
- #miss ⇒ Object
- #name ⇒ Object
- #p1 ⇒ Object
- #p2 ⇒ Object
- #pid ⇒ Object
- #set_ave(val) ⇒ Object (also: #ave=)
- #set_bms(bms) ⇒ Object (also: #bms=)
- #set_center_id(id) ⇒ Object (also: #center_id=)
- #set_dfact(val) ⇒ Object (also: #dfact=)
- #set_gds(gds) ⇒ Object (also: #gds=)
- #set_gid(id) ⇒ Object (also: #gid=)
- #set_initial(year, month, day, hour, min) ⇒ Object (also: #initial=)
- #set_miss(val) ⇒ Object (also: #miss=)
- #set_name_id(id) ⇒ Object (also: #name_id=)
- #set_p1(i) ⇒ Object (also: #p1=)
- #set_p2(i) ⇒ Object (also: #p2=)
- #set_pid(id) ⇒ Object (also: #pid=)
- #set_sub_center_id(id) ⇒ Object (also: #sub_center_id=)
- #set_time_range_id(id) ⇒ Object (also: #time_range_id=)
- #set_time_unit_id(id) ⇒ Object (also: #time_unit_id=)
- #set_version(ver) ⇒ Object (also: #version=)
- #set_z_id(id) ⇒ Object (also: #z_id=)
- #set_z_value(val) ⇒ Object (also: #z_value=)
- #sname ⇒ Object
- #standard_name ⇒ Object
- #sub_center ⇒ Object
- #time_range ⇒ Object
- #time_unit ⇒ Object
- #unit ⇒ Object
- #version ⇒ Object
- #z_sname ⇒ Object
- #z_type ⇒ Object
- #z_value ⇒ Object
Instance Method Details
#ave ⇒ Object
646 647 648 |
# File 'lib/numru/gphys/grib.rb', line 646 def ave return @pds.to_uint2(18) end |
#bms? ⇒ Boolean
495 496 497 498 |
# File 'lib/numru/gphys/grib.rb', line 495 def bms? flag = @pds.to_uint1(4) return (flag>>6)&1==1 end |
#center ⇒ Object
453 454 455 |
# File 'lib/numru/gphys/grib.rb', line 453 def center return CENTERS[cid] end |
#date ⇒ Object
607 608 609 610 611 612 613 |
# File 'lib/numru/gphys/grib.rb', line 607 def date d = Date.new((@pds.to_uint1(21)-1)*100 + @pds.to_uint1(9), @pds.to_uint1(10), @pds.to_uint1(11) ) h = [@pds.to_uint1(12), @pds.to_uint1(13)] return [d,h] end |
#dfact ⇒ Object
670 671 672 |
# File 'lib/numru/gphys/grib.rb', line 670 def dfact return str2int2( @pds[23,2] ) end |
#gds? ⇒ Boolean
476 477 478 479 |
# File 'lib/numru/gphys/grib.rb', line 476 def gds? flag = @pds.to_uint1(4) return (flag>>7)&1==1 end |
#get ⇒ Object
678 679 680 |
# File 'lib/numru/gphys/grib.rb', line 678 def get uint2str(length,3)<<@pds end |
#gid ⇒ Object
468 469 470 |
# File 'lib/numru/gphys/grib.rb', line 468 def gid return @pds.to_uint1(3) end |
#initial ⇒ Object
592 593 594 |
# File 'lib/numru/gphys/grib.rb', line 592 def initial return [@pds.to_uint1(21), @pds.to_uint1(9), @pds.to_uint1(10), @pds.to_uint1(11), @pds.to_uint1(12), @pds.to_uint1(13)] end |
#length ⇒ Object
442 443 444 |
# File 'lib/numru/gphys/grib.rb', line 442 def length @pds.length+3 end |
#miss ⇒ Object
654 655 656 |
# File 'lib/numru/gphys/grib.rb', line 654 def miss return @pds.to_uint1(20) end |
#name ⇒ Object
513 514 515 |
# File 'lib/numru/gphys/grib.rb', line 513 def name return param[0] end |
#p1 ⇒ Object
622 623 624 |
# File 'lib/numru/gphys/grib.rb', line 622 def p1 return @pds.to_uint1(15) end |
#p2 ⇒ Object
630 631 632 |
# File 'lib/numru/gphys/grib.rb', line 630 def p2 return @pds.to_uint1(16) end |
#pid ⇒ Object
460 461 462 |
# File 'lib/numru/gphys/grib.rb', line 460 def pid return @pds.to_uint1(2) end |
#set_ave(val) ⇒ Object Also known as: ave=
649 650 651 652 |
# File 'lib/numru/gphys/grib.rb', line 649 def set_ave(val) @pds[18,2] = uint2str(val,2) return val end |
#set_bms(bms) ⇒ Object Also known as: bms=
499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/numru/gphys/grib.rb', line 499 def set_bms(bms) flag = gds? ? 128 : 0 if bms flag += 64 @pds[4..4] = uint2str(flag,1) @sgm.bms.exist return true else @pds[4..4] = uint2str(flag,1) @sgm.bms.not_exist return false end end |
#set_center_id(id) ⇒ Object Also known as: center_id=
456 457 458 |
# File 'lib/numru/gphys/grib.rb', line 456 def set_center_id(id) @pds[1..1] = uint2str(id,1) end |
#set_dfact(val) ⇒ Object Also known as: dfact=
673 674 675 676 |
# File 'lib/numru/gphys/grib.rb', line 673 def set_dfact(val) @pds[23..24] = int2str(val,2) return val end |
#set_gds(gds) ⇒ Object Also known as: gds=
480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/numru/gphys/grib.rb', line 480 def set_gds(gds) flag = bms? ? 64 : 0 if gds flag += 128 @pds[4..4] = uint2str(flag,1) @sgm.gds.exist set_gid(255) return true else @pds[4..4] = uint2str(flag,1) @sgm.gds.not_exist return false end end |
#set_gid(id) ⇒ Object Also known as: gid=
471 472 473 474 |
# File 'lib/numru/gphys/grib.rb', line 471 def set_gid(id) @pds[3..3] = uint2str(id,1) return id end |
#set_initial(year, month, day, hour, min) ⇒ Object Also known as: initial=
595 596 597 598 599 600 601 602 603 604 605 |
# File 'lib/numru/gphys/grib.rb', line 595 def set_initial(year,month,day,hour,min) cent = year/100+1 year = year%100 @pds[21,1] = uint2str(cent,1) @pds[9,1] = uint2str(year,1) @pds[10,1] = uint2str(month,1) @pds[11,1] = uint2str(day,1) @pds[12,1] = uint2str(hour,1) @pds[13,1] = uint2str(min,1) return initial end |
#set_miss(val) ⇒ Object Also known as: miss=
657 658 659 660 |
# File 'lib/numru/gphys/grib.rb', line 657 def set_miss(val) @pds[20,1] = uint2str(val,1) return val end |
#set_name_id(id) ⇒ Object Also known as: name_id=
519 520 521 522 |
# File 'lib/numru/gphys/grib.rb', line 519 def set_name_id(id) @pds[5..5] = uint2str(id,1) return id end |
#set_p1(i) ⇒ Object Also known as: p1=
625 626 627 628 |
# File 'lib/numru/gphys/grib.rb', line 625 def set_p1(i) @pds[15,1] = uint2str(i,1) return i end |
#set_p2(i) ⇒ Object Also known as: p2=
633 634 635 636 |
# File 'lib/numru/gphys/grib.rb', line 633 def set_p2(i) @pds[16,1] = uint2str(i,1) return i end |
#set_pid(id) ⇒ Object Also known as: pid=
463 464 465 466 |
# File 'lib/numru/gphys/grib.rb', line 463 def set_pid(id) @pds[2..2] = uint2str(id,1) return id end |
#set_sub_center_id(id) ⇒ Object Also known as: sub_center_id=
665 666 667 668 |
# File 'lib/numru/gphys/grib.rb', line 665 def set_sub_center_id(id) @pds[22,1] = uint2str(id,1) return id end |
#set_time_range_id(id) ⇒ Object Also known as: time_range_id=
641 642 643 644 |
# File 'lib/numru/gphys/grib.rb', line 641 def set_time_range_id(id) @pds[17,1] = uint2str(id,1) return id end |
#set_time_unit_id(id) ⇒ Object Also known as: time_unit_id=
617 618 619 620 |
# File 'lib/numru/gphys/grib.rb', line 617 def set_time_unit_id(id) @pds[14,1] = uint2str(id,1) return id end |
#set_version(ver) ⇒ Object Also known as: version=
448 449 450 451 |
# File 'lib/numru/gphys/grib.rb', line 448 def set_version(ver) @pds[0..0] = uint2str(ver,1) return ver end |
#set_z_id(id) ⇒ Object Also known as: z_id=
544 545 546 547 |
# File 'lib/numru/gphys/grib.rb', line 544 def set_z_id(id) @pds[6..6] = uint2str(id,1) return id end |
#set_z_value(val) ⇒ Object Also known as: z_value=
577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'lib/numru/gphys/grib.rb', line 577 def set_z_value(val) type = @pds.to_uint1(6) ary = Z_LEVELS[type] val.length==ary.length || raise("length of val is not collect") if val.length==1 @pds[7,2] = uint2str(val[0],2) elsif val.length==2 @pds[7,1] = uint2str(val[0],1) @pds[8,1] = uint2str(val[1],1) else raise "length of val is too large" end return val end |
#sname ⇒ Object
524 525 526 527 528 529 530 |
# File 'lib/numru/gphys/grib.rb', line 524 def sname zid = @pds.to_uint1(6) sn = param[1] zt = Z_TYPES[zid] zn = zt ? zt[1] : zid.to_s return zn=="level" ? sn : sn+"_"+zn end |
#standard_name ⇒ Object
516 517 518 |
# File 'lib/numru/gphys/grib.rb', line 516 def standard_name return param[3] end |
#sub_center ⇒ Object
662 663 664 |
# File 'lib/numru/gphys/grib.rb', line 662 def sub_center return @pds.to_uint1(22) end |
#time_range ⇒ Object
638 639 640 |
# File 'lib/numru/gphys/grib.rb', line 638 def time_range return @pds.to_uint1(17) end |
#time_unit ⇒ Object
614 615 616 |
# File 'lib/numru/gphys/grib.rb', line 614 def time_unit return TIME_UNITS[ @pds.to_uint1(14) ] end |
#unit ⇒ Object
531 532 533 |
# File 'lib/numru/gphys/grib.rb', line 531 def unit return param[2] end |
#version ⇒ Object
445 446 447 |
# File 'lib/numru/gphys/grib.rb', line 445 def version return @pds.to_uint1 end |
#z_sname ⇒ Object
549 550 551 552 553 554 555 556 557 |
# File 'lib/numru/gphys/grib.rb', line 549 def z_sname zid = @pds.to_uint1(6) if zn = Z_TYPES[zid] return zn[1] else warn "z type (#{zid}) is not defined yet" return "unknown_#{zid}" end end |
#z_type ⇒ Object
534 535 536 537 538 539 540 541 542 543 |
# File 'lib/numru/gphys/grib.rb', line 534 def z_type zid = @pds.to_uint1(6) zt = Z_TYPES[zid] if zt return zt[0] else warn "z type (#{zid}) is not defined yet" return zid.to_s end end |
#z_value ⇒ Object
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'lib/numru/gphys/grib.rb', line 558 def z_value return @z_value if @z_value type = @pds.to_uint1(6) str = @pds[7,2] ary = Z_LEVELS[type] if ary.nil? ary = [] else ary = ary.dup end if ary.length==1 ary[0] = ary[0].dup.update( {"value"=> str.to_uint2} ) elsif ary.length==2 ary[0] = ary[0].dup.update( {"value"=> str.to_uint1} ) ary[1] = ary[1].dup.update( {"value"=> str.to_uint1(1)} ) end @z_value = ary return ary end |