galaxy.util
Utility functions and enumerations for handling datasets and legacy survey data.
Attributes
Classes
str(object='') -> str |
|
Enumeration of data sources. |
|
str(object='') -> str |
|
Enumeration for cluster classification. |
|
Enumeration for cluster classification. |
|
str(object='') -> str |
|
Enumeration for sample names. |
|
Enumeration for sample names. |
|
Enumeration for map types. |
Functions
|
Ensures the DataFrame has required and optional columns. |
|
Fetches a catalogue from Vizier and converts it to a pandas DataFrame. |
|
Fetches a catalogue from Vizier and converts it to a pandas DataFrame. |
|
Displays a progress bar for downloads. |
|
Converts a time string to HMS format. |
|
Converts a time string to DMS format. |
|
Divides a list into chunks of a specified size. |
|
Converts a 2-channel tensor to an RGB image tensor. |
Module Contents
- galaxy.util.PICS_SIZE = 224
- class galaxy.util.DataPart
Bases:
str
,enum.Enum
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.
- TRAIN = 'train'
- VALIDATE = 'validate'
- TEST = 'test'
- MC = 'mc'
- TEST_SAMPLE = 'test_sample'
- OTHERS = 'other'
- TO_NORMALIZE = 'normalization_sample'
- WISE_TO_NORMALIZE = 'normalize_wise'
- ACT_TO_NORMALIZE = 'normalize_act'
- class galaxy.util.DataSource
Bases:
str
,enum.Enum
Enumeration of data sources.
- MAP_ACT = 'map_act'
- DR5 = 'dr5'
- MC = 'mc'
- SGA = 'sga'
- TYC2 = 'tyc2'
- GAIA = 'gaia'
- UPC_SZ = 'upc_sz'
- SPT_SZ = 'spt_sz'
- PSZSPT = 'pszspt'
- CCOMPRASS = 'comprass'
- SPT2500D = 'spt2500d'
- SPTECS = 'sptecs'
- SPT100 = 'spt100'
- ACT_MCMF = 'act_mcmf'
- TEST_SAMPLE = 'test_sample'
- RANDOM = 'rand'
- RANDOM_BASED = 'rand_based'
- class galaxy.util.DataSurvey
Bases:
str
,enum.Enum
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.
- WISE = 'wise'
- ACT = 'act'
- ARTIFICIAL = 'artificial'
- class galaxy.util.IsCluster
Bases:
int
,enum.Enum
Enumeration for cluster classification.
- IS_CLUSTER = 1
- NOT_CLUSTER = 0
- ANY_OBJECT = 2
- class galaxy.util.IsObject
Bases:
int
,enum.Enum
Enumeration for cluster classification.
- UNKNOWN = -2
- IS_POINT = -1
- IS_CLUSTER = 0
- IS_GALAXY = 1
- IS_STAR = 2
- IS_RANDOM = 3
- ANY_OBJECT = 4
- galaxy.util.objects_naming: dict
- class galaxy.util.RedShiftType
Bases:
str
,enum.Enum
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.
- PHOT = 'phot'
- SPEC = 'spec'
- class galaxy.util.SampleName
Bases:
str
,enum.Enum
Enumeration for sample names.
- CLUSTER_SMALL = 'cluster_small'
- NEGATIVE_SMALL = 'random_small'
- TYC2_SMALL = 'tyc2_small'
- OTHER = 'other_small'
- class galaxy.util.SampleName2
Bases:
str
,enum.Enum
Enumeration for sample names.
- CLUSTER_SMALL = '0_small'
- NEGATIVE_SMALL = '1_small'
- OTHER_SMALL = '2_small'
- galaxy.util.sample_sizes: dict
- galaxy.util.plot_radius
- galaxy.util.sample_sources
- galaxy.util.required_columns
- galaxy.util.optional_columns
- galaxy.util.inherit_columns(frame: pandas.DataFrame) pandas.DataFrame
Ensures the DataFrame has required and optional columns.
- Args:
frame (pd.DataFrame): Input DataFrame.
- Returns:
pd.DataFrame: DataFrame with required and optional columns ensured.
- galaxy.util.read_vizier(catalogue: str) pandas.DataFrame
Fetches a catalogue from Vizier and converts it to a pandas DataFrame.
- Args:
catalogue (str): Name or identifier of the catalogue.
- Returns:
pd.DataFrame: DataFrame containing the catalogue data.
- galaxy.util.read_vizier_updated(catalogue: str, source: DataSource, target: IsCluster, survey: DataSurvey, object_type: IsObject, red_shift_type: RedShiftType | None = None, rename_dict: dict | None = None, row_limit=1000) pandas.DataFrame
Fetches a catalogue from Vizier and converts it to a pandas DataFrame.
- Args:
catalogue (str): Name or identifier of the catalogue.
- Returns:
pd.DataFrame: DataFrame containing the catalogue data.
- galaxy.util.bar_progress(current: int, total: int, width: int = 80) None
Displays a progress bar for downloads.
- Args:
current (int): Current number of bytes downloaded. total (int): Total number of bytes to download. width (int, optional): Width of the progress bar. Defaults to 80.
- galaxy.util.to_hms_format(time_str: str) str
Converts a time string to HMS format.
- Args:
time_str (str): Time string in space-separated format (e.g., “12 34 56”).
- Returns:
str: Time string in HMS format (e.g., “12h34m56s”).
- galaxy.util.to_dms_format(time_str: str) str
Converts a time string to DMS format.
- Args:
time_str (str): Time string in space-separated format (e.g., “12 34 56”).
- Returns:
str: Time string in DMS format (e.g., “12d34m56s”).
- galaxy.util.divide_chunks(data_list: List[Any], chunk_size: int) Generator[List[Any], None, None]
Divides a list into chunks of a specified size.
- Args:
data_list (List[Any]): Input list to divide. chunk_size (int): Size of each chunk.
- Yields:
Generator[List[Any], None, None]: Generator yielding list chunks.
- galaxy.util.fits_to_rgb_image(tensor: torch.Tensor) torch.Tensor
Converts a 2-channel tensor to an RGB image tensor.
- Args:
tensor (torch.Tensor): Input tensor of shape (2, H, W).
- Returns:
torch.Tensor: RGB image tensor of shape (3, H, W).
- Raises:
ValueError: If the input tensor does not have 2 channels.