rubyvanrooyen / xsats

Alert broker to dentify upcoming x-ray targets with SALT annulus overlap windows
GNU General Public License v3.0
0 stars 0 forks source link

JSON output for web scraping #3

Open rubyvanrooyen opened 3 years ago

rubyvanrooyen commented 3 years ago

Moving toward TOM Toolkit compatibility, the current web scripting scripts should accommodate JSON output as well as strings to file

This will allow the remote broker output to be ingested directly into the SALTVisibility evaluation as an object (dictionary) to search for on sky visibility period as well as possible overlap.

Current list of python scripts:

readCHANDRAwebdata.py
readGRBwebdata.py
readINTEGRALwebdata.py
readNICERwebdata.py
readNUSTARwebdata.py
readSWIFTwebdata.py
readXMMwebdata.py
rubyvanrooyen commented 3 years ago

Currently the main function holds all the implementation, example script readINTEGRALwebdata.py

With the output target strings generated for what appears to be 3 implementation scripts

# outputs for Steve Potters IDL routines
print(source[k],'\t',RAhrs[k],RAmins[k],int(float(RAsecs[k])),str(DECsign[k])+str(DECdeg[k]),DECarcmins[k],int(float(DECarcsecs[k])), file=listintegral)
...
# OUTPUT for SALTvisibility.py routine to determine SALT observability windows
print(source[k],'\t',RAhrs[k],RAmins[k],RAsecs[k],'\t',str(DECsign[k])+str(DECdeg[k]),DECarcmins[k],DECarcsecs[k],'\t','2000', file=targets)
...
# OUTPUT for GTIvsSALT.py routine to determine overlaps
print(source[k],'\t',str(startGTI[k]).replace('-',':').replace(' ',':'),'\t',str(endGTI[k]).replace('-',':').replace(' ',':'),'\t',duration[k],'\t','INTEGRAL', file=gtis)

Suggestion is to refractor the implementation into multiple modules:

rubyvanrooyen commented 3 years ago

Current output from web scraping scripts

Output strings

Suggested update to more general output from web scraping scripts

(See issue #5 for GTIvsSALT.py summary of output print statements) Required

name = f'{source}'
ra_str = f'{RAhrs} {RAmins} {int(float(RAsecs))}'
dec_str = f'{str(DECsign)}{str(DECdeg)} {DECarcmins} {int(float(DECarcsecs))}'
start_time = f'{str(startGTI).replace('-',':').replace(' ',':')}'
end_time = f'{str(endGTI).replace('-',':').replace(' ',':')}'
duration = duration

Optional or TBD

epoch = '2000'
salt_win_start = f'{str(SALTstart).replace('-',':').replace(' ',':')}'
salt_win_end = f'{str(SALTend).replace('-',':').replace(' ',':')}'
satellite = satellite

[Option 1]: Output strings

[Option 2]: Suggested JSON arguments:

[
  {
    "name":<str>, (default = name)
    "id":<int>, (default = iteration)
    "ra":<str>, ( default = ra_str)
    "dec":<str>, (default = dec_str)
    "epoch":<str>, (default = epoch )
    "salt_win_start":<str>, (default = salt_win_start)
    "salt_win_end":<str>, (default = salt_win_end)
    "start_time":<str>, (default = start_time)
    "end_time":<str>, (default = end_time)
    "duration":<float> (default = overlaplength)
    "satellite":<str> (optional, TBD)
  },
  ...
]
rubyvanrooyen commented 3 years ago

Implements SALT visibility evaluation IDL function (issue #4) Implements SALT vs GLI visibility overlap evaluation to obtain "start_time", "end_time", "duration" for JSON output (issue #5)