orca.utils.modelutils
Source model generation and manipulation utilities.
Provides functions for generating solar and sky source models, computing source positions, creating CASA component lists, and performing model visibility calculations for calibration and imaging.
Functions
|
Return J2000 coordinates of the solar disk center. |
|
Returns az ,el of sun in degrees. |
|
Return some basic information of an OVRO-LWA measurement set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The imagename, helio_imagename and reftime all can be a list. |
|
|
|
|
|
collect the fits file names of fast img |
|
This will create the list of [present name, future name] |
|
|
|
Can handle multiple images in a list. However if providing multiple images |
|
Get the x, y pixel location of the Sun from an all-sky image |
|
This function returns the rms of the data. As a first cut, it calculates |
|
|
|
|
|
This function corrects for the polarisation swap present in the fast MS data |
|
This function corrects for the amplitude correction present in the fast MS data |
|
Compress an OVRO-LWA fits file to a h5 files |
|
Recover a fits file from a compressed hdf5 file |
|
Check the consistency between a fits file and a hdf5 file, |
|
|
|
|
|
This is a utility function which returns the normalised beam factors for a single source. |
|
Module Contents
- orca.utils.modelutils.get_sun_pos(msfile: str, str_output: bool = True)[source]
Return J2000 coordinates of the solar disk center.
- Parameters:
msfile – Input CASA measurement set.
str_output – If True, return coordinate as CASA-compatible string. If False, return a CASA measures dictionary.
- Returns:
Solar disk center coordinate in string or dictionary format.
- orca.utils.modelutils.get_solar_altaz_multiple_times(times)[source]
- Parameters:
times – A astropy Time object. Can have multiple times
returns az,el in degrees for OVRO
- orca.utils.modelutils.get_solar_azel(msfile)[source]
Returns az ,el of sun in degrees.
- Parameters:
msfile (str) – Name of MS
- Returns:
az,el in degrees
- orca.utils.modelutils.get_msinfo(msfile)[source]
Return some basic information of an OVRO-LWA measurement set
- Parameters:
msfile – path to CASA measurement set
- Returns:
number of antennas, number of spectral windows, number of channels
- orca.utils.modelutils.convert_to_heliocentric_coords(msname, imagename, helio_imagename=None, reftime='')[source]
The imagename, helio_imagename and reftime all can be a list. If reftime is not provided, it is assumed to the the center of the observation time given in the MS
- orca.utils.modelutils.collect_fast_fits(imagename, pol='I')[source]
collect the fits file names of fast img
- Parameters:
imagename – the image name from previous step of imaging, (e.g., ‘sun_only’)
pol – the polarization of the image, default is ‘I’
- orca.utils.modelutils.rename_images(imagename, pol='I', img_prefix=None, intervals_out=1, channels_out=1)[source]
This will create the list of [present name, future name]
- Parameters:
imagename (str) – Imagename supplied to WSClean call.
pol (str) – Pol supplied to WSClean. Should be ‘,’ separated list. Parsing is strict. Default is I
img_prefix (str) – Image prefix of the renamed images. The times and freq will be appened after this, separated by ‘_’. Default is None. If None, img_prefix is set to imagename
intervals_out (int) – Intervals_out passed to WSClean. If 1, time_str is not appended to img_prefix. Default: 1
channels_out – Channels_out passed to WSClean. If 1, channels_out is not appended to img_prefix. Default :1
- Returns:
list of the renamed images. Blank list is returned if not present
- Return type:
- orca.utils.modelutils.correct_primary_beam(msfile, imagename, pol='I', fast_vis=False)[source]
Can handle multiple images in a list. However if providing multiple images provide full name of files. No addition to filename is done. If single file is provided, we can add ‘.image.fits’ to it.
- orca.utils.modelutils.get_solar_loc_pix(msfile, image='allsky')[source]
Get the x, y pixel location of the Sun from an all-sky image
- Parameters:
msfile – path to CASA measurement set
image – all sky image made from the measurement set
- Returns:
pixel value in X and Y for solar disk center
- orca.utils.modelutils.get_rms(data, thresh=7)[source]
This function returns the rms of the data. As a first cut, it calculates the std. Then it calculates the std again, by only considering pixels which are lower than the thresh*rms
- orca.utils.modelutils.swap_fastms_pols(msname)[source]
- This function corrects for the polarisation swap present in the fast MS data
the date on which the swap was corrected in the
X engine itself. Details of this isse has been discussed in https://github.com/ovro-lwa/lwa-issues/issues/486
- Parameters:
msname – Name of MS
: type msname: str :param correction_date: Datetime of correction in X-engine :type correction_date: Can be anything which is acceptable by Astropy Time
- orca.utils.modelutils.correct_fastms_amplitude_scale(msname)[source]
This function corrects for the amplitude correction present in the fast MS data correction_dates provides the date on which the ampltiude correction was done in data recorder itself. The amplitude of fast vis data was initially off by a factor of 4. On December 18, when trying to correct for this, this factor became 16. As of February 7, 2024, this has not been corrected. Details of this issue has been discussed in https://github.com/ovro-lwa/lwa-issues/issues/501
- Parameters:
msname – Name of MS
: type msname: str :param correction_date: Datetime of correction in X-engine :type correction_dates: Is a list of anything which is acceptable by Astropy Time
- orca.utils.modelutils.compress_fits_to_h5(fits_file, hdf5_file, beam_ratio=3.0, smaller_than_src=True, theoretical_beam_thresh=True, longest_baseline=3000, purge_corrupted=False, purge_thresh=1.5)[source]
Compress an OVRO-LWA fits file to a h5 files
- Parameters:
fits_file – the fits file to be compressed
hdf5_file – the h5 file to be saved. If not given, default to ‘{filename}.hdf’ in current directory
- orca.utils.modelutils.recover_fits_from_h5(hdf5_file, fits_out=None, return_data=False, return_meta_only=False)[source]
Recover a fits file from a compressed hdf5 file
- Parameters:
hdf5_file – the hdf5 file to be read
fits_out – the fits file to be recovered. If not given, default to ‘{filename}.fits’ in current directory
return_data – if True, return the fits data and header directly without creating the fits file
return_meta_only – if True, return only the metadata without creating the fits file
- Returns:
If return_data is True, returns a tuple (header, data). If return_meta_only is True, returns the metadata. Otherwise, returns None.
- orca.utils.modelutils.check_h5_fits_consistency(fits_file, hdf5_file=None, ignore_corrupted=False, work_dir='./', tolerance=0.001, ignore_ratio=2)[source]
Check the consistency between a fits file and a hdf5 file, if there is a hdf5 file, then compare the two files
- Parameters:
fits_file – the fits file to be compared
hdf5_file – the hdf5 file to be compared, if None then the hdf will be fits file replacing “.fits”
ignore_corrupted – if True, ignore the check of the data in the fits file corrupted data has -np.min*ignore_ratio>np.max
- orca.utils.modelutils.manual_split_corrected_ms(vis, outputvis, datacolumn='CORRECTED_DATA')[source]
- orca.utils.modelutils.get_primary_beam_single_source(alt, az, freq, model_beam_file='/lustre/msurajit/beam_model_nivedita/OVRO-LWA_soil_pt.h5')[source]
This is a utility function which returns the normalised beam factors for a single source. :param alt: altitude in degrees. float :param az: azimuth in degrees. float :param freq: Frequency in MHz :param model_beam_file: Location of the primary beam file