astronomy - Using the Ruby Date class for Astronomical data -


~ approximate solar noon

lw = 88.743  # longitude  jdate = date.ordinal_to_jd(time.now.year, time.now.yday) n = (jdate - 2451545 - 0.0009 - lw / 360).round  # lw users longitude west of 0. j_noon = 2451545 + 0.0009 + lw / 360 + n  puts j_noon  => 2455616.24740833 

as update, part of confusion solar noon calculations started since january 1, 4713 bc greenwich noon.

the correct use of date.ordinal_to_jd has not compensated fact. adding or subtracting 12 hours this:

jdn = date.ordinal_to_jd(time.now.year, time.now.yday) - 0.5 

we should less errors. use though since our calculations start yesterdays noon?

the code derived 2 equations page sunrise_equation.

the first answer got user here don't understand use of 0.0009 , lw / 360. lw / 360 appear fractional day of arc prime meridian. 0.0009, must small amount of variance in seconds since january 1, 4713 bc greenwich noon. see iau standards more info

i calculate 0.007776 seconds according page.

i have little bit of info date class not including method details.

        =begin --------------------------------------------------------------------- class: date class representing date.  see documentation file date.rb overview.  internally, date represented astronomical julian day number, ajd.  day of calendar reform, sg, stored, conversions other date formats.  (there of field time zone offset,  use of datetime subclass.)  new date object created using 1 of object creation class methods named   after corresponding date format, , arguments appropriate date format; instance, date::civil()  (aliased date::new()) year, month, , day-of-month, or date::ordinal() year , day-of-year.  of these object creation class methods take day of calendar reform optional argument.  date objects immutable once created.  once date has been created, date values can retrieved different date formats supported using instance methods. instance, #mon() gives civil month, #cwday() gives commercial day of week, , #yday() gives ordinal day of year. date values can retrieved in format, regardless of format used create date instance.  date class includes comparable module, allowing date objects compared , sorted, ranges of dates created, , forth.  ---------------------------------------------------------------------------------  includes: comparable(<, <=, ==, >, >=, between?)  constants: monthnames:      [nil] + %w(january february march april may june july august                             september october november december) daynames:        %w(sunday monday tuesday wednesday thursday friday saturday) abbr_monthnames: [nil] + %w(jan feb mar apr may jun jul aug sep oct nov dec) abbr_daynames:   %w(sun mon tue wed thu fri sat) italy:           2299161 england:         2361222 julian:          infinity.new gregorian:       -infinity.new  class methods: _load, _parse, _strptime, ajd_to_amjd, ajd_to_jd, amjd_to_ajd, civil, civil_to_jd, commercial, commercial_to_jd, day_fraction_to_time, gregorian?, gregorian_leap?, jd, jd_to_ajd, jd_to_civil, jd_to_commercial, jd_to_ld, jd_to_mjd, jd_to_ordinal, jd_to_wday, julian?, julian_leap?, ld_to_jd, mjd_to_jd, new, now, ordinal, ordinal_to_jd, parse, s3e, strptime, time_to_day_fraction, today, valid_civil?, valid_commercial?, valid_jd?, valid_ordinal?, valid_time?  instance methods: +, -, <<, <=>, ===, >>, _dump, ajd, amjd, asctime, civil, commercial, ctime, cwday, cweek, cwyear, day, day_fraction, downto, england, eql?, gregorian, gregorian?, hash, hour, inspect, italy, jd, julian, julian?, ld, leap?, mday, min, mjd, mon, month, new_offset, new_start, next, next_day, offset, ordinal, sec, sec_fraction, start, step, strftime, succ, time, to_s, to_yaml, upto, wday, weeknum0, weeknum1, wnum0,  wnum1, yday, year, zone  =end 

as side note, it's great ruby has way calculate julian-date. i'm looking javascript code noaa.

here class inspired write link.

class juliandaynumber    def initialize(year = 2000, month = 1, day = 1) #defaults jan. 01, 2000     @year = year     @month = month     @day = day   end    def calcjdn      if (@month <= 2)        @year -= 1       @month += 12     end      vara = (@year/100).floor     varb = 2 - vara + (vara/4).floor      jdn = (365.25*(@year + 4716)).floor \            + (30.6001*(@month+1)).floor \            + @day + varb - 1524.5      return jdn   end  end  jd = juliandaynumber.new(2011, 3, 2) julianday = jd.calcjdn puts julianday  => 2455622.5 

now gets me there i'm still researching way number such 1 calculated top equation. trying can see 0.5 in jdn. right? ruby or noaa?


noaa uses january 1st 2000 value of 2451545.0 subtracted jd time in fractional century this

    def calctimejuliancent(j)       t = (j - 2451545.0)/36525.0       return t     end  

ruby has number of ways of calculating julian day , need pick right one. noaa calculating jd since january 1, 4713 bc greenwich noon know. ends in .5 because leaving out fractional days.

ruby's julian day weird:

for scientific purposes, convenient refer date day count, counting arbitrary initial day. date first chosen january 1, 4713 bce. count of days date julian day number or julian date, abbreviated jd in date class. in local time, , counts midnight on initial day.

which makes no sense astronomical use. wait..

the stricter usage in utc, , counts midday on initial day. referred in date class astronomical julian day number, , abbreviated ajd. in date class, astronomical julian day number includes fractional days.

(rubydoc)

this looking for, ajd. without fractional days:

julianday = date.civil(@year, @month, @day).ajd puts julianday  => 2455622.5 

no need port 9 lines of javascript noaa. ruby's got back! ;)


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -