-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Iterate through time/lat/lon and calculate the sun's elevation at each point in time.
Uses the python "astral" library.
import xbatcher; import xarray; import time; import numpy as np; import zarr
start = time.time()
ds = xarray.open_dataset(
filename_or_obj=f"s3://noaa-wcsd-zarr-pds/level_2/Henry_B._Bigelow/HB0707/EK60/HB0707.zarr",
engine="zarr",
backend_kwargs={'storage_options': {'anon': True}},
chunks={},
cache=False
)
ds # Size: 7 GB
import pandas as pd
import astral
from astral import LocationInfo
from astral.sun import sun
location_info = LocationInfo(latitude=ds.latitude[0].values, longitude=ds.longitude[0].values)
astral.location.Location(latitude=ds.latitude[0].values, longitude=ds.longitude[0].values)
time_select = ds.time[0].values
time_select
#s = sun(location_info.observer, date=datetime.date(2009, 4, 22))
s = sun(location_info.observer, date=pd.Timestamp(time_select))
{
'dawn': datetime.datetime(2007, 7, 11, 8, 51, 25, 458091, tzinfo=datetime.timezone.utc),
'sunrise': datetime.datetime(2007, 7, 11, 9, 24, 57, 300734, tzinfo=datetime.timezone.utc),
'noon': datetime.datetime(2007, 7, 11, 16, 52, 40, tzinfo=datetime.timezone.utc),
'sunset': datetime.datetime(2007, 7, 11, 0, 20, 28, 225692, tzinfo=datetime.timezone.utc),
'dusk': datetime.datetime(2007, 7, 11, 0, 53, 59, 957281, tzinfo=datetime.timezone.utc)
}
sun_zenith_angle = astral.sun.zenith(observer=location_info.observer)
elevation_of_the_sun = astral.sun.elevation(observer=location_info.observer, dateandtime=pd.Timestamp(time_select))
zenith azimuth elevation sun
stral.sun.elevation(observer=location_info.observer)
city = LocationInfo("London", "England", "Europe/London", 51.5, -0.116)
print((
f"Information for {city.name}/{city.region}\n"
f"Timezone: {city.timezone}\n"
f"Latitude: {city.latitude:.02f}; Longitude: {city.longitude:.02f}\n"
))Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request