Class: When::CalendarNote::Ephemeris
- Inherits:
-
When::CalendarNote
- Object
- BasicTypes::Object
- TM::Object
- TM::ReferenceSystem
- When::CalendarNote
- When::CalendarNote::Ephemeris
- Defined in:
- lib/when_exe/ephemeris/notes.rb
Overview
天体暦の暦注
Constant Summary collapse
- Notes =
[When::BasicTypes::M17n, [ "locale:[=en:, ja=ja:, alias=ja:]", "names:[Ephemeris]", # 年の暦注 ---------------------------- [When::BasicTypes::M17n, "names:[year, 年]" ], # 月の暦注 ---------------------------- [When::BasicTypes::M17n, "names:[month, 月]", [When::BasicTypes::M17n, "names:[Month]" ] ], # 日の暦注 ---------------------------- [When::BasicTypes::M17n, "names:[day, 日]", "[Sunrise, 日の出 ]", # 日の出 "[Sunset, 日の入り ]", # 日の入り [When::Coordinates::Residue, "label:[Moon_Age=, 正午月齢=ja:%%<月齢>]", "divisor:60", "format:[%s(%4.1f)=]" ], "[Moonrise, 月の出 ]", # 月の出 "[Moonset=, 月の入り ]", # 月の入り [When::BasicTypes::M17n, "names:[Tide, 潮汐]", # 満潮干潮日時 "[High_Tide=en:Tide, 満潮=ja:%%<潮汐>]", "[Low_Tide=en:Tide, 干潮=ja:%%<潮汐>]" ], "[SolarTerm=, 二十四節気 ]", # 二十四節気 "[LunarPhase=, 月の位相 ]" # 月の位相 ] ]]
Constants inherited from When::CalendarNote
Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, HashProperty, Javanese, JulianDay, Mayan, Tibetan, Yis
Constants included from Parts::Resource
Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty
Constants included from Namespace
Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD
Instance Attribute Summary
Attributes inherited from When::CalendarNote
Attributes inherited from TM::ReferenceSystem
#domain_of_validity, #position
Attributes inherited from BasicTypes::Object
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#lunarphase(date, options = {}) ⇒ When::Coordinates::Residue
月の位相.
-
#moon_age(date, options = {}) ⇒ Numeric
正午月齢.
-
#moonrise(date, options = {}) ⇒ When::TM::TemporalPosition
月の出.
-
#moonset(date, options = {}) ⇒ When::TM::TemporalPosition
月の入り.
-
#solarterm(date, options = {}) ⇒ When::Coordinates::Residue
太陽黄経.
-
#sunrise(date, options = {}) ⇒ When::TM::TemporalPosition
日の出.
-
#sunset(date, options = {}) ⇒ When::TM::TemporalPosition
日の入り.
-
#tide(date, options = {}) ⇒ Array<Array<Integer, When::TM::TemporalPosotion>>
干潮・満潮の日時.
Methods inherited from When::CalendarNote
#copy, #day, #duration, #enum_for, #include?, #month, #note?, #notes, #year
Methods inherited from TM::ReferenceSystem
Methods included from Parts::Resource
#[], #^, _abbreviation_to_iri, _decode, _encode, _extract_prefix, _instance, _instantiate, _parse, _path_with_prefix, _replace_tags, _setup_, _setup_info, _simplify_path, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir
Methods included from Parts::Resource::Pool
#[], #[]=, #_pool, #_setup_, #pool_keys
Methods included from Parts::Resource::Synchronize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::Parts::Resource
Instance Method Details
#lunarphase(date, options = {}) ⇒ When::Coordinates::Residue
月の位相
435 436 437 438 439 440 441 |
# File 'lib/when_exe/ephemeris/notes.rb', line 435 def lunarphase(date, ={}) @phase ||= When.CalendarNote('LunarPhases') longitude, metsu = @phase.position(date) div, mod = longitude.divmod(90) return nil unless mod == 0 When.Resource('_co:Common::月相::*')[div] end |
#moon_age(date, options = {}) ⇒ Numeric
正午月齢
323 324 325 326 327 328 |
# File 'lib/when_exe/ephemeris/notes.rb', line 323 def moon_age(date, ={}) @phase ||= When.CalendarNote('LunarPhases') noon = date.floor(When::DAY,When::SYSTEM) noon += 0.5 if noon.kind_of?(When::TM::DateAndTime) @root['Moon_Age'][noon.to_f - @phase.phase(noon, [-30.0,30.0]).to_f] end |
#moonrise(date, options = {}) ⇒ When::TM::TemporalPosition
月の出
338 339 340 341 342 343 344 |
# File 'lib/when_exe/ephemeris/notes.rb', line 338 def moonrise(date, ={}) event = formula(date.location.iri).moonrise(date) event.events = [@root['Moonrise']] event rescue nil end |
#moonset(date, options = {}) ⇒ When::TM::TemporalPosition
月の入り
354 355 356 357 358 359 360 |
# File 'lib/when_exe/ephemeris/notes.rb', line 354 def moonset(date, ={}) event = formula(date.location.iri).moonset(date) event.events = [@root['Moonset']] event rescue nil end |
#solarterm(date, options = {}) ⇒ When::Coordinates::Residue
太陽黄経
418 419 420 421 422 423 424 425 |
# File 'lib/when_exe/ephemeris/notes.rb', line 418 def solarterm(date, ={}) @term ||= When.CalendarNote('SolarTerms') longitude, motsu = @term.position(date) return nil if motsu == 0 div, mod = longitude.divmod(15) return nil unless mod == 0 When.Resource('_co:Common::二十四節気::*')[div] end |
#sunrise(date, options = {}) ⇒ When::TM::TemporalPosition
日の出
291 292 293 294 295 296 297 |
# File 'lib/when_exe/ephemeris/notes.rb', line 291 def sunrise(date, ={}) event = formula(date.location.iri).sunrise(date) event.events = [@root['Sunrise']] event rescue nil end |
#sunset(date, options = {}) ⇒ When::TM::TemporalPosition
日の入り
307 308 309 310 311 312 313 |
# File 'lib/when_exe/ephemeris/notes.rb', line 307 def sunset(date, ={}) event = formula(date.location.iri).sunset(date) event.events = [@root['Sunset']] event rescue nil end |
#tide(date, options = {}) ⇒ Array<Array<Integer, When::TM::TemporalPosotion>>
干潮・満潮の日時
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/when_exe/ephemeris/notes.rb', line 375 def tide(date, ={}) return nil unless @interval @target ||= When.Resource('_ep:Moon') events = @root['Tide'] form = formula(date.location.iri) type = [:tide] =~ /\Ahorizon/i ? nil : 0 now = +date high_tides = [] 5.times do |i| high_tide = form.day_event(now + i - 2, type, @target) + @interval high_tides << high_tide if high_tides.size == 0 || high_tide > high_tides[-1] + 0.5 end tides = [] (high_tides.size-1).times do |i| tides << [0, high_tides[i]] tides << [1, 0.75*high_tides[i] + 0.25*high_tides[i+1]] tides << [0, 0.50*high_tides[i] + 0.50*high_tides[i+1]] tides << [1, 0.25*high_tides[i] + 0.75*high_tides[i+1]] end tides << [0, high_tides[-1]] today = +date.floor(When::DAY)...+date.ceil(When::DAY) seed = date._attr seed[:clock] ||= When::TM::Clock.local_time tides.select {|x| today.include?(x[1])}.map {|x| d = form._to_seed_type(x[1], seed) d.events = [events[x[0]]] d } rescue nil end |