Closed kimlai closed 10 months ago
Hmmmm I think so. Azimuth is angle above the horizon so that’s probably calculated to get sunrise (azimuth == 0). Been a while since I’ve revisited that lib so give me a day to see what I can do?Cheers, KipSent from my iPhoneOn 4 May 2023, at 14:56, kimlai @.***> wrote: Hello @kipcole9, I have a project where I need to compute the sun's azimuth and altitude for a given point and time. Something like this in pysolar. Is it something that can easily be derived from funcions in this package? I've seen sun_position_at but it seems to give an absolute position. Sorry if this is somehow a dumb question, I know absolutely nothing about astronomy :)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
Argh, incorrect. But I still think possible with not too much work. Will report back in the next 24 hours / if I think it will take longer I’ll let you know.Sent from my iPhoneOn 4 May 2023, at 15:22, Kip Cole @.> wrote:Hmmmm I think so. Azimuth is angle above the horizon so that’s probably calculated to get sunrise (azimuth == 0). Been a while since I’ve revisited that lib so give me a day to see what I can do?Cheers, KipSent from my iPhoneOn 4 May 2023, at 14:56, kimlai @.> wrote: Hello @kipcole9, I have a project where I need to compute the sun's azimuth and altitude for a given point and time. Something like this in pysolar. Is it something that can easily be derived from funcions in this package? I've seen sun_position_at but it seems to give an absolute position. Sorry if this is somehow a dumb question, I know absolutely nothing about astronomy :)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
@kimlai, should be straight forward for me to implement. Astro can already calculate right ascension and declination and its not too tricky to convert those to azimuth and altitude. I'll work on this over the weekend and should have it ready for you by Monday.
That's great, thank you so much. Let me know if I can help in any way.
Unfortunately I had some priority debugging to do on the weekend but that's finished now and I should be able to have something for you to try by end of Tueday. Sorry for missing the expectation I set.
Don't worry I'm in absolutely no rush. For now I'm hard-coding the results of pysolar
and it's working fine. When I'll need dynamic values I can always use a port, having it in Elixir would be really nice but I can get by without it.
Oh I'm definitely adding it ASAP, hate the idea of having to port out to Python for something like this. But now I'm curious - are you able to talk a little about what you're doing? Is there anything else Astro should be providing that would help?
I'm trying to generate an interactive map with a layer that shows which area will be in the shade at a given time and date. I'm using some elevation data (as .tiff files) to generate some so called "shadow maps". I don't think that I need anything beside the sun position from Astro, right now the difficulty that I have is that there are no Erlang/Elixir libraries that can generate a geotiff file from an in-memory bitmap, but I don't think that it's in your scope :)
Well not in scope for Astro. But maybe in scope for Image. As I understand it, the image data for GeoTiff files is standard Tiff. It's the metadata which is significantly augmented.
If that's the case there might be two approaches:
Use Image to write the Tiff image and an external tool to add the Geo metadata
Add GeoTiff metadata support to Image. Might not be too difficult.
Actually after doing some more testing it looks like I'm going to generate png images, not geotiffs. Right now images are generated on the client using javascript, but I was looking at this lib to generate them server side, as I like the idea of using a pure Erlang lib (the images are basically bitmap masks with 0 1 values), but I should I need more involved transformations I'll check out Image for sure. Anyway I've got a small proof of concept working so I'm pretty sure that I won't need anything else from Astro.
Cool, appreciate the observation.
My initial imaging attempts were pure elixir. I found the performance simply too slow. PNG is particularly expensive to encode. So I'll be curious to see how your experience is with the native lib.
I've added Astro.sun_azimuth_altitude/2 on the main
branch. I have tested against my current location and some online sources. The results seem correct in magnitude but around 1 degree variance with some online calculators.
It's tricky to verify what is accurate here. My code is based upon Meeus which is the "gold standard". The results are based upon sun apparent longitude which is corrected for aberration and nutation. Its not clear this is consistently applied in some online calculators.
Net net: I think this is right. But the results appear to be ~1 degree different (both for azimuth and altitude) to some online sources. I have not compared with the python lib you referenced. But if the difference is material I'm happy to compare implementations.
Anyway, would you consider giving this a test run and see if you're getting sensible, possibly acceptable or maybe even quite good results? And of course, please report back if the results seems to be complete crap for you.
Thanks for your patience, I needed some clear head time to get my head back into this and put the time in to implement.
One question you may be able to answer: Different sites report the azimuth in the range 0..360, others -180..180. I've used the first since that seems to be the convention I could see the most. Thoughts and expectations?
I've done a little more digging and I think using the NREL calculator is a reasonable reference. They report azimuth in either 0..360
or -180..180
range. Wikipedia seems to suggest either is ok.
My calculations are still ~1 degree out from this calculator which I'm not happy about but I can't see an obvious cause at this point other than refraction (which I don't take into account because I've not implemented a general calculation for it).
Good news is that the NREL
calculator does allow outputting of intermediate calculations so I have a path to explore further. Which I will do next.
@kimlai let me know if you have any feedback or suggestions? I'd like to publish to hex early next week otherwise.
Hello @kipcole9, sorry for not getting back to you, I was a bit swamped. I should be able to do some testing tomorrow, or this weekend 🤞
Nothing to apologise for! Just want to do my best to satisfy the requirement. I think it's close - but maybe not quite right yet so your feedback will help. Whenever you have the time.
I've published Astro version 1.0.0 that includes the Astro.sun_azimuth_altitude/2
function.
Hello @kipcole9,
I have a project where I need to compute the sun's azimuth and altitude for a given point and time. Something like this in pysolar. Is it something that can easily be derived from funcions in this package? I've seen sun_position_at but it seems to give an absolute position.
Sorry if this is somehow a dumb question, I know absolutely nothing about astronomy :)