From 206f2e538b2f6b819cf229fec34b6f6d55b30843 Mon Sep 17 00:00:00 2001 From: Akio Taniguchi Date: Fri, 9 Aug 2024 23:25:19 +0000 Subject: [PATCH] =?UTF-8?q?#189=20Update=20options=20of=20qlook=20commands?= =?UTF-8?q?=20(data=5Ftype=20=E2=86=92=20measure)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- decode/qlook.py | 83 +++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 51 deletions(-) diff --git a/decode/qlook.py b/decode/qlook.py index 35c2311..3aa025f 100644 --- a/decode/qlook.py +++ b/decode/qlook.py @@ -33,7 +33,6 @@ # constants DATA_FORMATS = "csv", "nc", "zarr", "zarr.zip" -DEFAULT_DATA_TYPE = "auto" DEFAULT_DEBUG = False DEFAULT_FIGSIZE = 12, 4 DEFAULT_FORMAT = "png" @@ -42,6 +41,7 @@ DEFAULT_INCL_MKID_IDS = None DEFAULT_MIN_FREQUENCY = None DEFAULT_MAX_FREQUENCY = None +DEFAULT_MEASURE = "brightness" DEFAULT_ROLLING_TIME = 200 DEFAULT_OUTDIR = Path() DEFAULT_OVERWRITE = False @@ -122,7 +122,7 @@ def daisy( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis rolling_time: int = DEFAULT_ROLLING_TIME, source_radius: str = "60 arcsec", @@ -151,8 +151,7 @@ def daisy( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). rolling_time: Moving window size. source_radius: Radius of the on-source area. Other areas are considered off-source in sky subtraction. @@ -187,7 +186,7 @@ def daisy( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, skycoord_units=skycoord_units, ) da = select.by(da, "state", exclude="GRAD") @@ -312,7 +311,7 @@ def pswsc( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, frequency_units: str = DEFAULT_FREQUENCY_UNITS, # options for saving format: str = DEFAULT_FORMAT, @@ -335,8 +334,7 @@ def pswsc( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). frequency_units: Units of the frequency axis. format: Output data format of the quick-look result. outdir: Output directory for the quick-look result. @@ -360,7 +358,7 @@ def pswsc( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, frequency_units=frequency_units, ) @@ -402,7 +400,7 @@ def raster( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -429,8 +427,7 @@ def raster( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -462,7 +459,7 @@ def raster( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, skycoord_units=skycoord_units, ) @@ -573,7 +570,7 @@ def skydip( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -598,8 +595,7 @@ def skydip( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -629,7 +625,7 @@ def skydip( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, ) # make continuum series @@ -670,7 +666,7 @@ def still( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -695,8 +691,7 @@ def still( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -726,7 +721,7 @@ def still( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, ) # make continuum series @@ -766,7 +761,7 @@ def xscan( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -791,8 +786,7 @@ def xscan( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -823,7 +817,7 @@ def xscan( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, # options for analysis chan_weight=chan_weight, pwv=pwv, @@ -845,7 +839,7 @@ def yscan( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -870,8 +864,7 @@ def yscan( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -902,7 +895,7 @@ def yscan( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, # options for analysis chan_weight=chan_weight, pwv=pwv, @@ -924,7 +917,7 @@ def zscan( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -949,8 +942,7 @@ def zscan( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -981,7 +973,7 @@ def zscan( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, # options for analysis chan_weight=chan_weight, pwv=pwv, @@ -1005,7 +997,7 @@ def _scan( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, # options for analysis chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx", pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0", @@ -1031,8 +1023,7 @@ def _scan( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``). chan_weight: Weighting method along the channel axis. uniform: Uniform weight (i.e. no channel dependence). std: Inverse square of temporal standard deviation of sky. @@ -1062,7 +1053,7 @@ def _scan( exclude_mkid_ids=exclude_mkid_ids, min_frequency=min_frequency, max_frequency=max_frequency, - data_type=data_type, + measure=measure, ) # make continuum series @@ -1187,7 +1178,7 @@ def load_dems( exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS, min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY, max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY, - data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE, + measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE, frequency_units: str = DEFAULT_FREQUENCY_UNITS, skycoord_units: str = DEFAULT_SKYCOORD_UNITS, ) -> xr.DataArray: @@ -1203,8 +1194,7 @@ def load_dems( Defaults to no minimum frequency bound. max_frequency: Maximum frequency to be included in analysis. Defaults to no maximum frequency bound. - data_type: Data type of the input DEMS file. - Defaults to the ``long_name`` attribute in it. + measure: Measure of the DataArray (either brightness or df/f). frequency_units: Units of the frequency. skycoord_units: Units of the sky coordinate axes. @@ -1212,7 +1202,7 @@ def load_dems( DEMS as a DataArray with given conversion and selections. """ - da = load.dems(dems, chunks=None) + da = load.dems(dems, measure=measure, chunks=None) if min_frequency is not None: min_frequency = Quantity(min_frequency).to(frequency_units).value @@ -1253,16 +1243,7 @@ def load_dems( max=max_frequency, ) - if data_type == "auto" and "units" in da.attrs: - return da - - if data_type == "brightness": - return da.assign_attrs(long_name="Brightness", units="K") - - if data_type == "df/f": - return da.assign_attrs(long_name="df/f", units="dimensionless") - - raise ValueError("Data type could not be inferred.") + return da def save_qlook(