Advertisement
mlot

Get-CurrentSFIK

May 9th, 2025
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Get-CurrentSFIK {
  2.     <#
  3.     .SYNOPSIS
  4.     Retrieves current Solor Flux Index and K Index information in JSON format from NOAA. It then returns the two
  5.     most current variables (SFI first and K-Index second).
  6.  
  7.     .EXAMPLE
  8.     $SFI, $K_INDEX = Get-CurrentSFIK
  9.  
  10.     .NOTES
  11.     https://www.arrl.org/files/file/Technology/tis/info/pdf/0209038.pdf
  12.     #>
  13.     try {
  14.         $flux = Invoke-RestMethod -Uri "https://services.swpc.noaa.gov/json/f107_cm_flux.json"
  15.         $kindex = Invoke-RestMethod -Uri "https://services.swpc.noaa.gov/json/boulder_k_index_1m.json"
  16.     } catch {
  17.         $PSCmdlet.ThrowTerminatingError($_)
  18.     }
  19.  
  20.     Return [int]$flux.flux[0], [int]$kindex.k_index[0]
  21. }
  22.  
  23. $sfi, $kindex = Get-CurrentSFIK
  24.  
  25. Write-Host "Current SFI: $sfi`nCurrent K Index: $kindex"
  26.  
  27. if ( ($sfi -gt 149) -and ($kindex -lt 3) ) {
  28.     Write-Host -ForegroundColor Yellow "Good HF Propagation Conditions!"
  29. } elseif ( ($sfi -gt 199) -and ($kindex -lt 3) ) {
  30.     Write-Host -ForegroundColor Green "Excellent HF Propagation Conditions!"
  31. }
  32.  
  33. Exit(0)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement