xmd79

Astro: Celestial Coordinates

Apr 7th, 2023
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © BarefootJoey
  3.  
  4. // ██████████████████████████████████████████████████████████████████████ _____ __ _ _______ _____ _______ _______ _______
  5. // █▄─▄─▀██▀▄─██▄─▄▄▀█▄─▄▄─█▄─▄▄─█─▄▄─█─▄▄─█─▄─▄─███▄─▄█─▄▄─█▄─▄▄─█▄─█─▄█ | | \ | |______ |_____] |_____| | |______
  6. // ██─▄─▀██─▀─███─▄─▄██─▄█▀██─▄███─██─█─██─███─███─▄█─██─██─██─▄█▀██▄─▄██ __|__ | \_| ______| | | | |_____ |______
  7. // █▄▄▄▄██▄▄█▄▄█▄▄█▄▄█▄▄▄▄▄█▄▄▄███▄▄▄▄█▄▄▄▄██▄▄▄██▄▄▄███▄▄▄▄█▄▄▄▄▄██▄▄▄██
  8.  
  9. //@version=5
  10. indicator("Astro: Celestial Coordinates", overlay=false)
  11.  
  12. import BarefootJoey/AstroLib/1 as AL
  13.  
  14. planet_in = input.string("☿ Mercury", "Which planet?", options=["☉︎ Sun", "☽︎ Moon", "☿ Mercury", "♀ Venus", "🜨 Earth", "♂ Mars", "♃ Jupiter", "♄ Saturn", "⛢ Uranus", "♆ Neptune", "♇ Pluto"])
  15. orbital_in = input.string("Declination", "Which Orbital Element?", options=["Longitude", "Latitude", "RA", "Altitude", "Declination"])
  16. showlast = input.int(2000, "Show last?", minval=1, tooltip="Number of historical plots to display. The fewer plots, the faster the load time (especially on loweer timeframes). Use the Time Machine feature for distant historical analysis.")
  17. iTxtSize=input.string("Normal", title="Label Size", options=["Auto", "Tiny", "Small", "Normal", "Large"], inline="4l")
  18. vTxtSize=iTxtSize == "Auto" ? size.auto : iTxtSize == "Tiny" ? size.tiny : iTxtSize == "Small" ? size.small : iTxtSize == "Normal" ? size.normal : iTxtSize == "Large" ? size.large : size.small
  19. d_t = input.bool(false, "Date & Time?", tooltip="Leave this unchecked to display date only.", inline="4l")
  20. lookback = input.int(3, "Lookback", minval=3)
  21. col_info = input.color(color.white, "Info Color")
  22. position = input.string(position.top_center, "Info Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left])
  23.  
  24. grtm = "🕜 Time Machine 🕜"
  25. gsd = input.bool(false, "Activate Time Machine", group=grtm)
  26. sdms = input.time(timestamp("2022-03-28T00:00:00+00:00"), "Select Date", group=grtm)
  27. gt = gsd ? sdms : time
  28.  
  29. grol = "🔭 Observer Location 🔭"
  30. htz = input.float(0, "Timezone Hour", step=0.5, inline="2", group=grol)
  31. mtz = input.int(0, "Minute", minval=0, maxval=45, inline="2", group=grol)
  32. tz = htz + math.round(mtz / 60, 4)
  33. latitude = input.float(0, "Latitude", inline="1", group=grol)
  34. longitude = input.float(0, "Longitude", inline="1", group=grol)
  35.  
  36. geo = input.bool(true, "Geocentric?", tooltip="Leave this box unchecked for heliocentric. Only applies to Longitude calculations.")
  37. geoout = geo ? 1 : 0
  38.  
  39. day = AL.J2000(AL.JDN(gt, 0, tz))
  40. dayr = AL.J2000(AL.JDN(gt, 1, tz))
  41.  
  42. orbital_out = orbital_in == "Longitude" ? geoout : orbital_in == "Latitude" ? 2 : orbital_in == "RA" ? 5 : orbital_in == "Altitude" ? 4 : orbital_in == "Declination" ? 3 : na
  43.  
  44. moonout = AL.getmoon(orbital_out, day, dayr, latitude, longitude)
  45. sunout = AL.getsun(orbital_out, day, dayr, latitude, longitude, tz)
  46. mercout = AL.getplanet(1,orbital_out, day, dayr, latitude, longitude, tz)
  47. venuout = AL.getplanet(2,orbital_out, day, dayr, latitude, longitude, tz)
  48. eartout = AL.getplanet(3,orbital_out, day, dayr, latitude, longitude, tz)
  49. marsout = AL.getplanet(4,orbital_out, day, dayr, latitude, longitude, tz)
  50. jupiout = AL.getplanet(5,orbital_out, day, dayr, latitude, longitude, tz)
  51. satuout = AL.getplanet(6,orbital_out, day, dayr, latitude, longitude, tz)
  52. uranout = AL.getplanet(7,orbital_out, day, dayr, latitude, longitude, tz)
  53. neptout = AL.getplanet(8,orbital_out, day, dayr, latitude, longitude, tz)
  54. plutout = AL.getplanet(9,orbital_out, day, dayr, latitude, longitude, tz)
  55.  
  56. planet_out = planet_in == "☉︎ Sun" ? sunout : planet_in == "☽︎ Moon" ? moonout : planet_in == "☿ Mercury" ? mercout : planet_in == "♀ Venus" ? venuout : planet_in == "🜨 Earth" ? eartout : planet_in == "♂ Mars" ? marsout : planet_in == "♃ Jupiter" ? jupiout : planet_in == "♄ Saturn" ? satuout : planet_in == "⛢ Uranus" ? uranout : planet_in == "♆ Neptune" ? neptout : planet_in == "♇ Pluto" ? plutout : na
  57. col_out = planet_in == "☉︎ Sun" ? color.yellow : planet_in == "☽︎ Moon" ? color.silver : planet_in == "☿ Mercury" ? color.maroon : planet_in == "♀ Venus" ? color.green : planet_in == "🜨 Earth" ? color.blue : planet_in == "♂ Mars" ? color.red : planet_in == "♃ Jupiter" ? color.orange : planet_in == "♄ Saturn" ? color.gray : planet_in == "⛢ Uranus" ? color.navy : planet_in == "♆ Neptune" ? color.fuchsia : planet_in == "♇ Pluto" ? color.black : na
  58. post_tt_out = orbital_in == "Longitude" ? "°" : orbital_in == "Latitude" ? "°" : orbital_in == "RA" ? "" : orbital_in == "Altitude" ? "°" : orbital_in == "Declination" ? "°" : na
  59.  
  60. hi = planet_out[2]<planet_out[1] and planet_out[1]>planet_out
  61. lo = planet_out[2]>planet_out[1] and planet_out[1]<planet_out
  62. hi_out = ta.valuewhen(hi, planet_out, 0)
  63. lo_out = ta.valuewhen(lo, planet_out, 0)
  64.  
  65. transp=0
  66. plot(planet_out, color=color.new(col_out,transp), style=plot.style_line, show_last=showlast, linewidth=2)
  67.  
  68. var label orbital = na
  69. if barstate.islast
  70. orbital := label.new(bar_index, y=planet_out, text=planet_in, size=size.small, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(col_out,0), tooltip=planet_in + "\n" + orbital_in + "\n" + str.tostring(planet_out, "#.##") + post_tt_out) //AL.deg_to_time(speed_out))
  71. label.delete(orbital[1])
  72.  
  73. geo_tt = geo ? " (Geo)" : " (Helio)"
  74. long_tt = orbital_in == "Longitude" ? geo_tt : ""
  75.  
  76. var table Info = na
  77. table.delete(Info)
  78. Info := table.new(position, 1, 1)
  79. if barstate.islast
  80. table.cell(Info, 0, 0,
  81. text = planet_in + " " + orbital_in + long_tt,
  82. text_size = vTxtSize,
  83. text_color = color.new(col_info,0))
  84.  
  85. //-------------------------------Pivots---------------------------------------//
  86. pivot_in = planet_out
  87. left = lookback
  88. right = left
  89.  
  90. ms_per_bar = time[1] - time[2]
  91. pivot_time(now_time) => (time - (left * ms_per_bar))
  92. time_out = str.format_time(pivot_time(time), d_t?"MM-dd-yyyy\nHH:mm":"MM-dd-yyyy", syminfo.timezone)
  93.  
  94. p_hi = ta.pivothigh(pivot_in, left, right)
  95. var label hi_lab = na
  96. if p_hi
  97. hi_lab:= label.new(x=bar_index-left, y=p_hi, text=time_out, size=size.small, color=color.new(color.gray, 100), textcolor=col_info, style=label.style_label_down, tooltip=orbital_in + ": " + str.tostring(planet_out[left], "#.##") + post_tt_out)
  98.  
  99. p_lo = ta.pivotlow(pivot_in, left, right)
  100. var label lo_lab = na
  101. if p_lo
  102. lo_lab:= label.new(x=bar_index-left, y=p_lo, text=time_out, size=size.small, color=color.new(color.gray, 100), textcolor=col_info, style=label.style_label_up, tooltip=orbital_in + ": " + str.tostring(planet_out[left], "#.##") + post_tt_out)
  103.  
  104. // EoS made w/ ❤ by @BarefootJoey ✌💗📈
Advertisement
Add Comment
Please, Sign In to add comment