David's Astronomy Pages
Notes - Session 1021 Attempt (2022-07-07)

 
Bullet Session Aims & Highlights
 - Observing Result
 - Night Summary Plot
 - Session Event Log
Bullet Operational Issues
  - Critical Issues (0),  Major Issues (0),  Minor Issues (2),  Small Defects (1),  Continuous Improvement (5)
 
Bullet No images from session     [ Local Files >> ]    
Bullet Apple WeatherKit (successor to Dark Sky Weather API)
   

Session Aims & Highlights (2022-07-07)

Main aims

  1. AstroMain. Check out fixes and new features in 3.52.2 version of AstroMain. Ensure that new version hasn't introduced any new issues. 
  2. Targets.  Acquire images of a selection of variable stars, nearby stars, comets & deep sky targets as allowed by time & twilight conditions.

 Equipment & Software

Highlights

Notes:

  Summary Plots & Logs

Observing Plan
No plan was generated for the session 
  
Observing Result (S2021A)
Image
   
Dome & Scope Slewing Performance
No data
  
Night Sky Summary Plot
Top axis: Sky Brightness at Zenith (in ADU/s)
Lefthand axis: Local Time (hh LT). Righthand axis: Sun Altitude (degs)

Image   
  
Actual Weather vs Pre-Session Weather Forecast
Image
Image   
  
Session Event Log
Time     Event Detail
23:08:17 Session Monitoring AutoStart monitoring for Live Session opportunity between 23:24 & 01:51
23:08:18   AutoStart Waiting AutoStart waiting till earliest start time at 23:24
23:24:54   AutoStart Delayed Session delayed due to cloud
00:17:54 Session AutoStarting Session autostarting (00:17)
00:18:34   Camera1 Connected SBIG Camera Connected (set point -10°C)
00:18:36 Session Created Live Session Created (2022-07-07 S01021, ImageSaveNum: 1021001)
00:18:38   Scope Switched On Telescope Power has been switched on via UPB Powerbox.
00:20:18   Services Started Observatory Services started
00:20:25 Observatory (Auto) Observatory placed in Fully-Automated Mode
00:20:29 Session Pending Session pending (2022-07-07)
00:20:31 Session Initiating Session initiating (2022-07-07)
00:20:33   Plan Requested Observing Plan requested from AstroPlan (1.30.8)
00:21:11   Plan Loaded Observing Plan loaded to queue (Plan ID: 781)
00:21:25   Camera1 Connected SBIG Camera Connected (set point -10°C)
00:21:31   Telescope Connected Telescope Connected (TheSky6)
00:21:55 Session Equilibration Session ready for dome & camera equilibration
00:23:35 Wait On Weather Waiting for acceptable conditions
00:23:37 Session Suspended Session suspended
00:23:39   Dome Closed Dome already closed (closure time is unknown)
00:23:41   Queue Started Observing Queue started (9 targets selected)
00:43:47     Target Cancelled Target cancelled (1/9, 61 Cyg) due to cloud
00:59:50     Target Cancelled Target cancelled (2/9, GCVS SS Cyg) due to cloud
01:09:11     Target Cancelled Target cancelled (3/9, GCVS BL Lac) due to cloud
01:18:39     Target Cancelled Target cancelled (4/9, GCVS EV Lac) due to cloud
01:37:50     Target Cancelled Target cancelled (5/9, NGC 6701 w/AT2022nxe) due to cloud
01:47:40     Target Cancelled Target cancelled (6/9, Vega) due to cloud
02:00:57     Target Cancelled Target cancelled (7/9, GCVS RR Lyr) due to cloud
02:08:33     Target Cancelled Target cancelled (8/9, Vega) due to cloud
02:27:39     Target Cancelled Target cancelled (9/9, KIC 8462852) due to cloud
02:27:44   Queue Completed Job Queue completed
02:27:46 Session Closing Session closing
02:27:51   Dome Closed Dome already closed (closure time is unknown)
02:27:52   Dome Parked Dome already parked (parking time is unknown)
02:28:55   Telescope Parked Telescope parked (parking time 62s)
02:29:10   Telescope State Scope parked Turn scope off. (Handbox)
02:29:32   Telescope Switched Off Telescope Power has been switched off via UPB Switch.
02:30:28   Services Stopped Night Services stopped
02:30:30 Session Housekeeping Housekeeping Started (Cleanup FITS, Create Fits Summary, Transfer Files)
02:30:31 Session Finished Session Finished
 
 
Session Alerts
Time     Alert Detail
-- No Alerts                --                              
 
 

Back to Top


Operational Issues (2022-07-07, S1021A)

[ Prev | Next ]

Critical Issues

Major Issues

Minor Issues

Small Defects

Continuous ImprovementContinuous Improvement

[ Prev | Next ]

Back to Top


Apple WeatherKit (successor to Dark Sky Weather API)

Introduction
Apple Inc bought out DarkSky company a couple of years ago, and indicated that DarkSky Site and API would become no longer available at some point. The API has continued to function and provide weather information for the Clair Observatory, but an announcement from Apple on 2022-06-13 stated that from March 31st, 2023 the Dark Sky API will no longer be available and encouraged users to migrate to WeatherKit, a new Apple API available on iOS, iPadOS, macOS, tvOS, and web will that provide access to the new Apple Weather forecast data.  DarkSky was free for up to 1000 API calls per day.  AppleKit is free for up to 500,000 calls/month with membership of Apple Developer Program.

Details about WeatherKit can be found at https://developer.apple.com/weatherkit/
and at https://betterprogramming.pub/wwdc22-get-started-with-weatherkit-202794853c01

Proposal
The new WeatherKit API should be investigated and if suitable its use should be built into AstroWeather.

The key components of the program
- Join Apple Developer Program
- Creating and signed a Developer Token for accessing WeatherKit
- Create a working REST API request (with authentication header) that pulls weather data from WeatherKit


Apple Developer Program
Membership of Apple Developer Program requires AppleID with 2-factor authentication turned-on in order to enroll.  Membership of AppleKit allows up to 500,000 calls/month free during & after program development

Enable WeatherKit on App ID
In Certificates, Identifiers & Profiles, click Identifiers in the sidebar.

  1. On the top left, click the add button (+), select App IDs, then click Continue.
  2. Register an App ID.
  3. Click the App Services tab.
  4. Select the WeatherKit checkbox.
  5. Click Continue, review the registration information, and click Register.



Note : Remember to also enable WeatherKit in the App Capabilities tab when editing your App ID.

Rest API
 
 DarkSky :         https://api.darksky.net/forecast/{secretkey}/{latitude},{longitude}?units=uk2
 WeatherKit :  GET https://weatherkit.apple.com/api/v1/weather/{language}/{latitude}/{longitude}:

The header of every WeatherKit REST API request requires a signed developer token to identify the authorized ADP member and application or service making the request.  WeatherKit only supports developer tokens signed with the ES256 algorithm,

Decoded Token looks like:
{
"alg": "ES256",
"kid": "ABC123DEFG",
"id": "DEF123GHIJ.com.example.weatherkit-client"
}
{
"iss": "DEF123GHIJ",
"iat": 1437179036,
"exp": 1493298100,
"sub": "com.example.weatherkit-client"
}

Request authentication for WeatherKit REST API : 
https://developer.apple.com/documentation/weatherkitrestapi/request_authentication_for_weatherkit_rest_api

Create Token :  https://jwt.io/

Pass the developer token as a parameter to the Authorization: Bearer header in each request. Here's an example of a request:
curl -v -H 'Authorization: Bearer [developer token]' "https://weatherkit.apple.com/api/v1/availability/{latitude}/{longitude}?country=US"

Looking at VB.Net code examples suggest the following style of coding could be used:

Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse

myReq = HttpWebRequest.Create("https://meineURI.net")

myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("username:password")))
Dim myData As String = "yourDataHere"
myReq.GetRequestStream.Write(System.Text.Encoding.UTF8.GetBytes(myData), 0, System.Text.Encoding.UTF8.GetBytes(myData).Count)
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd

result will be a HttpResponseMessage, and result.Content.ReadAsStringAsync should give you back the JSON data as a string.

Epoch Convertor for getting iat, exp

https://www.epochconverter.com/

Step 1 : Image Add 2-factor authentication to existing Apple Account
Step 2 : Image Enroll in Apple Developer Program (annoying to find it cost £79/year to enroll as individual)
Step 3 : Image Record Team Name and Team ID
Step 4:  Image Create Key (WeatherKit), Create Service ID,
Step 5:  Image Create JWT Developer Token   ' see C:\Data\Computer\Apple Developer\WeatherKit\JWT_Token_2022-07-19.txt

Step 6:  Image CreateTWeatherKit class and WeatherKit object in AstroWeather, based on DarkSky class & object
Step 7:  Image Modify .BuildRequest  for WeatherKit Rest API
Step 8:  Image Modify .SendRequest to pass the JWT developer token as a parameter to the Authorization: Bearer header for request
Step 9:  Image Create btnWeatherKitForecast button and GetWeatherKitForecast() routine
Step 10a:Image Test GetWeatherKitForecast().  Failing with exception on line myReq.GetRequestStream() : 
                   "The request was aborted: Could not create SSL/TLS secure channel."
Step 10b:Image Add additional code line  ServicePointManager.SecurityProtocol = 3072
Step 10c:Image Retest GetWeatherKitForecast().  Failing with exception :  but VS provided no details about the exception
Step 10d:Image Retest GetWeatherKitForecast().  Failing with exception on line myResp = myReq.GetResponse
                  "The remote server returned an error: (403) Forbidden."  (i.e. server refuses to fulfill the request).
Step 10e:Image   Added additional code lines  
  Dim postData As String = ""
  Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
  myReq.ContentLength = byteArray.Length
  dataStream = myReq.GetRequestStream()
  dataStream.Write(byteArray, 0, byteArray.Length)
Step 10f:Image Retest GetWeatherKitForecast().  Failing with exception on line myResp = myReq.GetResponse
                  "The remote server returned an error: (403) Forbidden."  (i.e. server refuses to fulfill the request).
Step 10g     Changed code to use
   Dim MyWebClient As New WebClient
   MyWebClient.Headers.Add("Authorization", token) 
       '  also tried with "Authorization: Bearer", token   and with "Authorization", "Bearer " + token
   MyWebClient.DownloadFile(Request, JSON_File)

Update 2023-06-01

After investigation and review it was decided not to pursue the WeatherKit API option due to i) difficult & inadequate support/help, ii) cost of annual developer program fee, iii) doesn't replace some useful attributes that were in DarkSky Api, iv) another (free) option, OpenWeather API is available which supports equivalent functionality (though still not as good as DarkSky API).

Back to Top