Skip to content

Commit

Permalink
Merge pull request #125 from casangi/118-extract_locit
Browse files Browse the repository at this point in the history
118 extract locit
  • Loading branch information
vsmagalhaes authored Aug 1, 2023
2 parents 980a94d + a072df5 commit f33db53
Show file tree
Hide file tree
Showing 7 changed files with 958 additions and 445 deletions.
561 changes: 151 additions & 410 deletions docs/visualization_tutorial.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/astrohack/_utils/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
length_factors = [1e3, 1609.34, 1.0, 0.9144, 0.3048, 0.0254, 1e-2, 1e-3, 1e-6, 25.4/1e6]

# Trigonometric units
trigo_units = ['rad', 'deg']
trigo_units = ['rad', 'deg', 'hour']
# from rad to unit
trigo_factors = [1.0, constants.pi/180.]
trigo_factors = [1.0, constants.pi/180., constants.pi/12.]

unit_dict = {
'length': length_units,
Expand Down
105 changes: 75 additions & 30 deletions src/astrohack/_utils/_dio.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DIMENSION_KEY = "_ARRAY_DIMENSIONS"
CALLING_FUNCTION=1


def _check_if_file_exists(file):
logger = _get_astrohack_logger()
caller = inspect.stack()[CALLING_FUNCTION].function
Expand Down Expand Up @@ -82,41 +83,85 @@ def _load_panel_file(file=None, panel_dict=None, dask_load=True):
return panel_data_dict


def _load_image_file(file=None, image_dict=None, dask_load=True):
""" Open hologgraphy file.
def _load_image_file(file=None, image_dict=None, dask_load=True):
""" Open hologgraphy file.
Args:s
file (str, optional): Path to holography file. Defaults to None.
Args:s
file (str, optional): Path to holography file. Defaults to None.
Returns:
bool: bool describing whether the file was opened properly
"""
logger = _get_astrohack_logger()
ant_data_dict = {}
Returns:
bool: bool describing whether the file was opened properly
"""
logger = _get_astrohack_logger()
ant_data_dict = {}

if image_dict is not None:
ant_data_dict = image_dict
if image_dict is not None:
ant_data_dict = image_dict

ant_list = [dir_name for dir_name in os.listdir(file) if os.path.isdir(file)]

try:
for ant in ant_list:
if 'ant' in ant:
ddi_list = [dir_name for dir_name in os.listdir(file + "/" + str(ant)) if os.path.isdir(file + "/" + str(ant))]
ant_data_dict[ant] = {}

for ddi in ddi_list:
if 'ddi' in ddi:
if dask_load:
ant_data_dict[ant][ddi] = xr.open_zarr("{name}/{ant}/{ddi}".format(name=file, ant=ant, ddi=ddi))
else:
ant_data_dict[ant][ddi] = _open_no_dask_zarr("{name}/{ant}/{ddi}".format(name=file, ant=ant, ddi=ddi))

except Exception as e:
logger.error(str(e))
raise
ant_list = [dir_name for dir_name in os.listdir(file) if os.path.isdir(file)]

try:
for ant in ant_list:
if 'ant' in ant:
ddi_list = [dir_name for dir_name in os.listdir(file + "/" + str(ant)) if
os.path.isdir(file + "/" + str(ant))]
ant_data_dict[ant] = {}

for ddi in ddi_list:
if 'ddi' in ddi:
if dask_load:
ant_data_dict[ant][ddi] = xr.open_zarr(
"{name}/{ant}/{ddi}".format(name=file, ant=ant, ddi=ddi))
else:
ant_data_dict[ant][ddi] = _open_no_dask_zarr(
"{name}/{ant}/{ddi}".format(name=file, ant=ant, ddi=ddi))

except Exception as e:
logger.error(str(e))
raise

return ant_data_dict

return ant_data_dict

def _load_locit_file(file=None, locit_dict=None, dask_load=True):
""" Open Antenna position (locit) file.
Args:
file (str, optional): Path to holography file. Defaults to None.
Returns:
bool: bool describing whether the file was opened properly
"""
logger = _get_astrohack_logger()
ant_data_dict = {}

if locit_dict is not None:
ant_data_dict = locit_dict

ant_list = [dir_name for dir_name in os.listdir(file) if os.path.isdir(file)]

ant_data_dict['obs_info'] = _read_meta_data(f'{file}/.observation_info')
ant_data_dict['ant_info'] = {}
try:
for ant in ant_list:
if 'ant' in ant:
ddi_list = [dir_name for dir_name in os.listdir(file + "/" + str(ant)) if
os.path.isdir(file + "/" + str(ant))]
ant_data_dict[ant] = {}
ant_data_dict['ant_info'][ant] = _read_meta_data(f'{file}/{ant}/.antenna_info')
for ddi in ddi_list:
if 'ddi' in ddi:
if dask_load:
ant_data_dict[ant][ddi] = xr.open_zarr(
"{name}/{ant}/{ddi}".format(name=file, ant=ant, ddi=ddi))
else:
ant_data_dict[ant][ddi] = _open_no_dask_zarr(
"{name}/{ant}/{ddi}".format(name=file, ant=ant, ddi=ddi))
except Exception as e:
logger.error(str(e))
raise
return ant_data_dict


def _load_holog_file(holog_file, dask_load=True, load_pnt_dict=True, ant_id=None, ddi_id=None, holog_dict=None):
Expand Down
Loading

0 comments on commit f33db53

Please sign in to comment.