Skip to content

Commit 4ae94db

Browse files
committed
#189 Update options of qlook commands (data_type → measure)
1 parent 48104c1 commit 4ae94db

File tree

1 file changed

+32
-51
lines changed

1 file changed

+32
-51
lines changed

decode/qlook.py

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
# constants
3535
DATA_FORMATS = "csv", "nc", "zarr", "zarr.zip"
36-
DEFAULT_DATA_TYPE = "auto"
3736
DEFAULT_DEBUG = False
3837
DEFAULT_FIGSIZE = 12, 4
3938
DEFAULT_FORMAT = "png"
@@ -42,6 +41,7 @@
4241
DEFAULT_INCL_MKID_IDS = None
4342
DEFAULT_MIN_FREQUENCY = None
4443
DEFAULT_MAX_FREQUENCY = None
44+
DEFAULT_MEASURE = "brightness"
4545
DEFAULT_ROLLING_TIME = 200
4646
DEFAULT_OUTDIR = Path()
4747
DEFAULT_OVERWRITE = False
@@ -122,7 +122,7 @@ def daisy(
122122
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
123123
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
124124
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
125-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
125+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
126126
# options for analysis
127127
rolling_time: int = DEFAULT_ROLLING_TIME,
128128
source_radius: str = "60 arcsec",
@@ -151,8 +151,7 @@ def daisy(
151151
Defaults to no minimum frequency bound.
152152
max_frequency: Maximum frequency to be included in analysis.
153153
Defaults to no maximum frequency bound.
154-
data_type: Data type of the input DEMS file.
155-
Defaults to the ``long_name`` attribute in it.
154+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
156155
rolling_time: Moving window size.
157156
source_radius: Radius of the on-source area.
158157
Other areas are considered off-source in sky subtraction.
@@ -187,7 +186,7 @@ def daisy(
187186
exclude_mkid_ids=exclude_mkid_ids,
188187
min_frequency=min_frequency,
189188
max_frequency=max_frequency,
190-
data_type=data_type,
189+
measure=measure,
191190
skycoord_units=skycoord_units,
192191
)
193192
da = select.by(da, "state", exclude="GRAD")
@@ -311,7 +310,7 @@ def pswsc(
311310
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
312311
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
313312
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
314-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
313+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
315314
frequency_units: str = DEFAULT_FREQUENCY_UNITS,
316315
# options for saving
317316
format: str = DEFAULT_FORMAT,
@@ -334,8 +333,7 @@ def pswsc(
334333
Defaults to no minimum frequency bound.
335334
max_frequency: Maximum frequency to be included in analysis.
336335
Defaults to no maximum frequency bound.
337-
data_type: Data type of the input DEMS file.
338-
Defaults to the ``long_name`` attribute in it.
336+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
339337
frequency_units: Units of the frequency axis.
340338
format: Output data format of the quick-look result.
341339
outdir: Output directory for the quick-look result.
@@ -359,7 +357,7 @@ def pswsc(
359357
exclude_mkid_ids=exclude_mkid_ids,
360358
min_frequency=min_frequency,
361359
max_frequency=max_frequency,
362-
data_type=data_type,
360+
measure=measure,
363361
frequency_units=frequency_units,
364362
)
365363

@@ -401,7 +399,7 @@ def raster(
401399
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
402400
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
403401
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
404-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
402+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
405403
# options for analysis
406404
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
407405
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -428,8 +426,7 @@ def raster(
428426
Defaults to no minimum frequency bound.
429427
max_frequency: Maximum frequency to be included in analysis.
430428
Defaults to no maximum frequency bound.
431-
data_type: Data type of the input DEMS file.
432-
Defaults to the ``long_name`` attribute in it.
429+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
433430
chan_weight: Weighting method along the channel axis.
434431
uniform: Uniform weight (i.e. no channel dependence).
435432
std: Inverse square of temporal standard deviation of sky.
@@ -461,7 +458,7 @@ def raster(
461458
exclude_mkid_ids=exclude_mkid_ids,
462459
min_frequency=min_frequency,
463460
max_frequency=max_frequency,
464-
data_type=data_type,
461+
measure=measure,
465462
skycoord_units=skycoord_units,
466463
)
467464

@@ -571,7 +568,7 @@ def skydip(
571568
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
572569
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
573570
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
574-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
571+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
575572
# options for analysis
576573
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
577574
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -596,8 +593,7 @@ def skydip(
596593
Defaults to no minimum frequency bound.
597594
max_frequency: Maximum frequency to be included in analysis.
598595
Defaults to no maximum frequency bound.
599-
data_type: Data type of the input DEMS file.
600-
Defaults to the ``long_name`` attribute in it.
596+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
601597
chan_weight: Weighting method along the channel axis.
602598
uniform: Uniform weight (i.e. no channel dependence).
603599
std: Inverse square of temporal standard deviation of sky.
@@ -627,7 +623,7 @@ def skydip(
627623
exclude_mkid_ids=exclude_mkid_ids,
628624
min_frequency=min_frequency,
629625
max_frequency=max_frequency,
630-
data_type=data_type,
626+
measure=measure,
631627
)
632628

633629
# make continuum series
@@ -668,7 +664,7 @@ def still(
668664
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
669665
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
670666
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
671-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
667+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
672668
# options for analysis
673669
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
674670
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -693,8 +689,7 @@ def still(
693689
Defaults to no minimum frequency bound.
694690
max_frequency: Maximum frequency to be included in analysis.
695691
Defaults to no maximum frequency bound.
696-
data_type: Data type of the input DEMS file.
697-
Defaults to the ``long_name`` attribute in it.
692+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
698693
chan_weight: Weighting method along the channel axis.
699694
uniform: Uniform weight (i.e. no channel dependence).
700695
std: Inverse square of temporal standard deviation of sky.
@@ -724,7 +719,7 @@ def still(
724719
exclude_mkid_ids=exclude_mkid_ids,
725720
min_frequency=min_frequency,
726721
max_frequency=max_frequency,
727-
data_type=data_type,
722+
measure=measure,
728723
)
729724

730725
# make continuum series
@@ -764,7 +759,7 @@ def xscan(
764759
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
765760
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
766761
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
767-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
762+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
768763
# options for analysis
769764
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
770765
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -789,8 +784,7 @@ def xscan(
789784
Defaults to no minimum frequency bound.
790785
max_frequency: Maximum frequency to be included in analysis.
791786
Defaults to no maximum frequency bound.
792-
data_type: Data type of the input DEMS file.
793-
Defaults to the ``long_name`` attribute in it.
787+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
794788
chan_weight: Weighting method along the channel axis.
795789
uniform: Uniform weight (i.e. no channel dependence).
796790
std: Inverse square of temporal standard deviation of sky.
@@ -821,7 +815,7 @@ def xscan(
821815
exclude_mkid_ids=exclude_mkid_ids,
822816
min_frequency=min_frequency,
823817
max_frequency=max_frequency,
824-
data_type=data_type,
818+
measure=measure,
825819
# options for analysis
826820
chan_weight=chan_weight,
827821
pwv=pwv,
@@ -843,7 +837,7 @@ def yscan(
843837
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
844838
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
845839
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
846-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
840+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
847841
# options for analysis
848842
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
849843
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -868,8 +862,7 @@ def yscan(
868862
Defaults to no minimum frequency bound.
869863
max_frequency: Maximum frequency to be included in analysis.
870864
Defaults to no maximum frequency bound.
871-
data_type: Data type of the input DEMS file.
872-
Defaults to the ``long_name`` attribute in it.
865+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
873866
chan_weight: Weighting method along the channel axis.
874867
uniform: Uniform weight (i.e. no channel dependence).
875868
std: Inverse square of temporal standard deviation of sky.
@@ -900,7 +893,7 @@ def yscan(
900893
exclude_mkid_ids=exclude_mkid_ids,
901894
min_frequency=min_frequency,
902895
max_frequency=max_frequency,
903-
data_type=data_type,
896+
measure=measure,
904897
# options for analysis
905898
chan_weight=chan_weight,
906899
pwv=pwv,
@@ -922,7 +915,7 @@ def zscan(
922915
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
923916
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
924917
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
925-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
918+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
926919
# options for analysis
927920
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
928921
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -947,8 +940,7 @@ def zscan(
947940
Defaults to no minimum frequency bound.
948941
max_frequency: Maximum frequency to be included in analysis.
949942
Defaults to no maximum frequency bound.
950-
data_type: Data type of the input DEMS file.
951-
Defaults to the ``long_name`` attribute in it.
943+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
952944
chan_weight: Weighting method along the channel axis.
953945
uniform: Uniform weight (i.e. no channel dependence).
954946
std: Inverse square of temporal standard deviation of sky.
@@ -979,7 +971,7 @@ def zscan(
979971
exclude_mkid_ids=exclude_mkid_ids,
980972
min_frequency=min_frequency,
981973
max_frequency=max_frequency,
982-
data_type=data_type,
974+
measure=measure,
983975
# options for analysis
984976
chan_weight=chan_weight,
985977
pwv=pwv,
@@ -1003,7 +995,7 @@ def _scan(
1003995
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
1004996
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
1005997
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
1006-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
998+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
1007999
# options for analysis
10081000
chan_weight: Literal["uniform", "std", "std/tx"] = "std/tx",
10091001
pwv: Literal["0.5", "1.0", "2.0", "3.0", "4.0", "5.0"] = "5.0",
@@ -1029,8 +1021,7 @@ def _scan(
10291021
Defaults to no minimum frequency bound.
10301022
max_frequency: Maximum frequency to be included in analysis.
10311023
Defaults to no maximum frequency bound.
1032-
data_type: Data type of the input DEMS file.
1033-
Defaults to the ``long_name`` attribute in it.
1024+
measure: Measure in analysis (either ``'brightness'`` or ``'df/f'``).
10341025
chan_weight: Weighting method along the channel axis.
10351026
uniform: Uniform weight (i.e. no channel dependence).
10361027
std: Inverse square of temporal standard deviation of sky.
@@ -1060,7 +1051,7 @@ def _scan(
10601051
exclude_mkid_ids=exclude_mkid_ids,
10611052
min_frequency=min_frequency,
10621053
max_frequency=max_frequency,
1063-
data_type=data_type,
1054+
measure=measure,
10641055
)
10651056

10661057
# make continuum series
@@ -1185,7 +1176,7 @@ def load_dems(
11851176
exclude_mkid_ids: Optional[Sequence[int]] = DEFAULT_EXCL_MKID_IDS,
11861177
min_frequency: Optional[str] = DEFAULT_MIN_FREQUENCY,
11871178
max_frequency: Optional[str] = DEFAULT_MAX_FREQUENCY,
1188-
data_type: Literal["auto", "brightness", "df/f"] = DEFAULT_DATA_TYPE,
1179+
measure: Literal["brightness", "df/f"] = DEFAULT_MEASURE,
11891180
frequency_units: str = DEFAULT_FREQUENCY_UNITS,
11901181
skycoord_units: str = DEFAULT_SKYCOORD_UNITS,
11911182
) -> xr.DataArray:
@@ -1201,16 +1192,15 @@ def load_dems(
12011192
Defaults to no minimum frequency bound.
12021193
max_frequency: Maximum frequency to be included in analysis.
12031194
Defaults to no maximum frequency bound.
1204-
data_type: Data type of the input DEMS file.
1205-
Defaults to the ``long_name`` attribute in it.
1195+
measure: Measure of the DataArray (either brightness or df/f).
12061196
frequency_units: Units of the frequency.
12071197
skycoord_units: Units of the sky coordinate axes.
12081198
12091199
Returns:
12101200
DEMS as a DataArray with given conversion and selections.
12111201
12121202
"""
1213-
da = load.dems(dems, chunks=None)
1203+
da = load.dems(dems, measure=measure, chunks=None)
12141204

12151205
if min_frequency is not None:
12161206
min_frequency = Quantity(min_frequency).to(frequency_units).value
@@ -1251,16 +1241,7 @@ def load_dems(
12511241
max=max_frequency,
12521242
)
12531243

1254-
if data_type == "auto" and "units" in da.attrs:
1255-
return da
1256-
1257-
if data_type == "brightness":
1258-
return da.assign_attrs(long_name="Brightness", units="K")
1259-
1260-
if data_type == "df/f":
1261-
return da.assign_attrs(long_name="df/f", units="dimensionless")
1262-
1263-
raise ValueError("Data type could not be inferred.")
1244+
return da
12641245

12651246

12661247
def save_qlook(

0 commit comments

Comments
 (0)