suncasa.utils.helioimage2fits
Attributes
Functions
|
|
|
Function to normalize any angles to between the lower limit and upper limit |
|
|
|
Function to convert observatory name or id to coordinates used by JPL Horizons |
|
This function visits JPL Horizons to retrieve J2000 topocentric RA and DEC of the solar disk center |
|
Module ot read CASA measurement set and return RA, DEC, and time stamps of the phase center. |
|
Module for calculating offsets of the phase center to the solar disk center using the following steps |
|
|
|
main routine to register CASA images |
|
return the phase center in RA and DEC of a given solar coordinates |
|
composing a sunpy compatible fits from a fits file with RA and DEC in the header |
Module Contents
- suncasa.utils.helioimage2fits.normalize(angle, lower=-np.pi, upper=np.pi)[source]
Function to normalize any angles to between the lower limit and upper limit :param angle: input angle in radians :param lower: lower bound of the normalization, default to -pi :param upper: upper bound of the normalization, default to pi :return: normalized angle in radians
- suncasa.utils.helioimage2fits.observatory_to_coord(observatory)[source]
Function to convert observatory name or id to coordinates used by JPL Horizons Coordinate system is specified as ‘geodetic longitude (deg), geodetic latitude (deg), altitude above reference ellipsoid (km)’ See https://ssd.jpl.nasa.gov/horizons/manual.html#center for detailed documentation
- suncasa.utils.helioimage2fits.read_horizons(t0=None, dur=None, vis=None, observatory=None, verbose=False, use_astropy=False)[source]
This function visits JPL Horizons to retrieve J2000 topocentric RA and DEC of the solar disk center as a function of time.
Keyword arguments: t0: Referece time in astropy.Time format dur: duration of the returned coordinates in days. Default to 1 minute vis: CASA visibility dataset (in measurement set format). If provided, use entire duration from
the visibility data
- observatory: observatory code (from JPL Horizons). If not provided, use information from visibility.
if no visibility found, use earth center (code=500)
verbose: True to provide extra information use_astropy: whether or not to use astropy to obtain the empheris
Usage: >>> from astropy.time import Time >>> out = read_horizons(t0=Time(‘2017-09-10 16:00:00’), observatory=’-81’) >>> out = read_horizons(vis = ‘mydata.ms’)
- suncasa.utils.helioimage2fits.read_msinfo(vis=None, msinfofile=None, interp_to_scan=False, verbose=False)[source]
Module ot read CASA measurement set and return RA, DEC, and time stamps of the phase center. Options for returning those from the emphemeris table (if available) or use those from the FIELD table. :param vis: :type vis: (required) path to the input CASA measurement set :param msinfofile: :type msinfofile: (optional) path/name of the saved numpy .npz file :param #use_ephem: :type #use_ephem: (optional) if True (default), use the enclosed emphemeris table, otherwise use RA/DEC of the FIELD table :param interp_to_scan: are interpolated to the beginning of each scan. This is mainly for backward compatibility. Default is False. :type interp_to_scan: (optional) if True, the entries of the emphemeris table
- Returns:
msinfo – vis: CASA measurement set observatory: Name of the observatory. May be used if they default to phase at the solar center. scans: summary info of the scans fieldids: a list of all FIELD ids scan_start_times: list of the start times of all scans, in mjd scan_end_times: list of the end times of all scans, in mjd btimes: time stamps used by ephem_to_helio() to determine the image/phase center shifts, in mjd ras: corresponding RA coordinates used by ephem_to_helio() to determine the image/phase center shifts, in rad decs: corresponding DEC coordinates used by ephem_to_helio() to determine the image/phase center shifts, in rad
- Return type:
A dictionary contains necessary information for ephem_to_helio()
- suncasa.utils.helioimage2fits.ephem_to_helio(vis=None, ephem=None, msinfo=None, reftime=None, dopolyfit=True, usephacenter=True, geocentric=False, verbose=False)[source]
Module for calculating offsets of the phase center to the solar disk center using the following steps 1. Take a solar ms database, read the scan and field information, find out the phase centers (in RA and DEC).
This step is done with read_msinfo()
Compare with the ephemeris of the solar disk center (in RA and DEC)
Record RA/DEC of the phase center and offsets in RA/DEC and Helioprojective Cartesian coordinates (solar X/Y) inputs:
msinfo: CASA MS information, output from read_msinfo ephem: solar ephem, output from read_horizons reftime: list of reference times (e.g., used for imaging)
CASA standard time format, either a single time (e.g., ‘2012/03/03/12:00:00’ or a time range (e.g., ‘2012/03/03/12:00:00~2012/03/03/13:00:00’. If the latter, take the midpoint of the timerange for reference. If no date specified, take the date of the first scan
- dopolyfit: Bool. Default: True. Works for MS database with only one source with continously tracking.
Disabled if usephacenter=False.
- usephacenter: Bool – if True, correct for the RA and DEC in the ms file based on solar empheris.
Otherwise assume the phasecenter is pointed to the solar disk center (EOVSA case)
- geocentric: Bool – if True, use geocentric RA & DEC.
If False, use topocentric RA & DEC based on observatory location Default: False
- return values:
- helio: a list of VLA pointing information
reftimestr: reference time, in FITS format string reftime: reference time, in mjd format ra: actual RA of phasecenter in the ms file at the reference time (interpolated) dec: actual DEC of phasecenter in the ms file at the reference time (interpolated) # CASA uses only RA and DEC of the closest field (e.g. in clean) # ra_fld: RA of the CASA reference pointing direction, in radian dec_fld: DEC of the CASA reference pointing direction, in radian ra0: RA of the solar disk center, in radian dec0: DEC of the solar disk center, in radian raoff: RA offset of the phasecenter in the ms file to solar disk center, in arcsec decoff: DEC offset of the phasecenter in the ms file to solar disk center, in arcsec refx: heliocentric X offset of the phasecenter in the ms file to solar disk center, in arcsec refy: heliocentric Y offset of the phasecenter in the ms file to solar disk center, in arcsec has_ephem_table: flag to indicate if there is an ephemeris table attached.
- ######## Example #########
from suncasa.utils import helioimage2fits as hf vis = vis = ‘22B-174_20221031_sun.1s.cal.ms’ ephem = hf.ephem_to_helio(vis=vis, reftime=’2022/10/31/20:37:10~2022/10/31/20:37:20’, dopolyfit=True,
usephacenter=True, verbose=True)
- # Read out the ms information takes some time. To save time, one can read out the ms information first
and supply the record here for registering multiple images. It will skip the read_msinfo() step.
msinfo = hf.read_msinfo(vis=vis, verbose=True) ephem = hf.ephem_to_helio(vis=vis, msinfo=msinfo, reftime=’2022/10/31/20:37:10~2022/10/31/20:37:20’,
dopolyfit=True, usephacenter=True, verbose=True)
- suncasa.utils.helioimage2fits.imreg(vis=None, imagefile=None, timerange=None, ephem=None, msinfo=None, fitsfile=None, usephacenter=True, geocentric=False, dopolyfit=True, reftime=None, offsetfile=None, beamfile=None, toTb=False, sclfactor=1.0, p_ang=None, overwrite=True, deletehistory=False, subregion='', docompress=False, verbose=False)[source]
- main routine to register CASA images
- Required Inputs:
vis: STRING. CASA measurement set from which the image is derived imagefile: STRING or LIST. name of the input CASA image timerange: STRING or LIST. timerange used to generate the CASA image, must have the same length as the input images.
Each element should be in CASA standard time format, e.g., ‘2012/03/03/12:00:00~2012/03/03/13:00:00’
- Optional Inputs:
msinfo: DICTIONARY. CASA MS information, output from read_msinfo. If not provided, generate one from the supplied vis ephem: DICTIONARY. solar ephem, output from read_horizons.
If not provided, query JPL Horizons based on time info of the vis (internet connection required)
fitsfile: STRING or LIST. name of the output registered fits files toTb: Bool. Convert the default Jy/beam to brightness temperature? sclfactor: scale the image values up by its value (e.g., sclfactor = 100 to compensate VLA 20 dB attenuator) p_ang: solar p angle in degrees. If provided, use the supplied value and ignore the empheris verbose: Bool. Show more diagnostic info if True. usephacenter: Bool – if True, correct for the RA and DEC in the ms file based on solar empheris.
Otherwise assume the phasecenter is correctly pointed to the solar disk center (EOVSA case)
- geocentric: Bool – if True, use geocentric RA & DEC.
If False, use topocentric RA & DEC based on observatory location Default: False
- dopolyfit: Bool – if True, fit the ephemeris from the measurement set using a polynomial fit.
if False, just use linear interpolation
###### The following two parameters are only meant for temporary fixes ######################## reftime: STRING or LIST. ONLY USED IF ANOTHER TIME (OTHER THAN TIME TO MAKE THE IMAGE)
IS NEEDED TO FIND RA AND DEC. Each element should be in CASA standard time format, e.g., ‘2012/03/03/12:00:00’
subregion: only write the data within the sub-region selection. See ‘help par.region’ for details.
Usage: >>> from suncasa.utils import helioimage2fits as hf >>> hf.imreg(vis=’mydata.ms’, imagefile=’myimage.image’, fitsfile=’myimage.fits’,
timerange=’2017/08/21/20:21:10~2017/08/21/20:21:18’)
The output fits file is ‘myimage.fits’
History: BC (sometime in 2014): function was first wrote, followed by a number of edits by BC and SY BC (2019-07-16): Added checks for stokes parameter. Verified that for converting from Jy/beam to brightness temperature,
the convention of 2*k_b*T should always be used. I.e., for unpolarized source, stokes I, RR, LL, XX, YY, etc. in the output CASA images from (t)clean should all have same values of radio intensity (in Jy/beam) and brightness temperature (in K).
- suncasa.utils.helioimage2fits.calc_phasecenter_from_solxy(vis, timerange='', xycen=None, usemsphacenter=True, observatory=None, verbose=False)[source]
return the phase center in RA and DEC of a given solar coordinates
- Parameters:
vis – input measurement sets file
timerange – can be a string or astropy.time.core.Time object, or a 2-element list of string or Time object
xycen – solar x-pos and y-pos in arcsec
usemsphacenter
- Returns:
phasecenter midtim: mid time of the given timerange
- suncasa.utils.helioimage2fits.radec_fits_to_helio(fits_in, helio_sunpy_fits_name=None, obs_loc=EarthLocation(lat=37.232259 * u.deg, lon=-118.28479 * u.deg), fov=None)[source]
composing a sunpy compatible fits from a fits file with RA and DEC in the header using location of OVSA as example
- Parameters:
fits_in – input fits file
helio_sunpy_fits_name – output fits file name, if None, the output file will be named as fits_in.replace(‘.fits’, ‘_heliosunpy.fits’)
obs_loc – location of the observer, default is OVSA