diff --git a/decode/qlook.py b/decode/qlook.py index 44c7dc6..f91a8f1 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") @@ -311,7 +310,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, @@ -334,8 +333,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. @@ -359,7 +357,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, ) @@ -401,7 +399,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", @@ -428,8 +426,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. @@ -461,7 +458,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, ) @@ -571,7 +568,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", @@ -596,8 +593,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. @@ -627,7 +623,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 @@ -668,7 +664,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", @@ -693,8 +689,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. @@ -724,7 +719,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 @@ -764,7 +759,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", @@ -789,8 +784,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. @@ -821,7 +815,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, @@ -843,7 +837,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", @@ -868,8 +862,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. @@ -900,7 +893,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, @@ -922,7 +915,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", @@ -947,8 +940,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. @@ -979,7 +971,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, @@ -1003,7 +995,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", @@ -1029,8 +1021,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. @@ -1060,7 +1051,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 @@ -1185,7 +1176,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: @@ -1201,8 +1192,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. @@ -1210,7 +1200,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 @@ -1251,16 +1241,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(