xradio 0.0.56__py3-none-any.whl → 0.0.59__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. xradio/__init__.py +2 -2
  2. xradio/_utils/_casacore/casacore_from_casatools.py +12 -2
  3. xradio/_utils/_casacore/tables.py +1 -0
  4. xradio/_utils/coord_math.py +22 -23
  5. xradio/_utils/dict_helpers.py +76 -11
  6. xradio/_utils/schema.py +5 -2
  7. xradio/_utils/zarr/common.py +1 -73
  8. xradio/image/_util/_casacore/xds_from_casacore.py +49 -33
  9. xradio/image/_util/_casacore/xds_to_casacore.py +41 -14
  10. xradio/image/_util/_fits/xds_from_fits.py +146 -35
  11. xradio/image/_util/casacore.py +4 -3
  12. xradio/image/_util/common.py +4 -4
  13. xradio/image/_util/image_factory.py +8 -8
  14. xradio/image/image.py +45 -5
  15. xradio/measurement_set/__init__.py +19 -9
  16. xradio/measurement_set/_utils/__init__.py +1 -3
  17. xradio/measurement_set/_utils/_msv2/__init__.py +0 -0
  18. xradio/measurement_set/_utils/_msv2/_tables/read.py +17 -76
  19. xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py +2 -685
  20. xradio/measurement_set/_utils/_msv2/conversion.py +174 -156
  21. xradio/measurement_set/_utils/_msv2/create_antenna_xds.py +9 -16
  22. xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py +128 -222
  23. xradio/measurement_set/_utils/_msv2/msv2_to_msv4_meta.py +1 -2
  24. xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py +8 -7
  25. xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py +31 -74
  26. xradio/measurement_set/_utils/_msv2/partition_queries.py +1 -261
  27. xradio/measurement_set/_utils/_msv2/subtables.py +0 -107
  28. xradio/measurement_set/_utils/_utils/interpolate.py +60 -0
  29. xradio/measurement_set/_utils/_zarr/encoding.py +2 -7
  30. xradio/measurement_set/convert_msv2_to_processing_set.py +0 -2
  31. xradio/measurement_set/load_processing_set.py +2 -2
  32. xradio/measurement_set/measurement_set_xdt.py +20 -16
  33. xradio/measurement_set/open_processing_set.py +1 -3
  34. xradio/measurement_set/processing_set_xdt.py +54 -841
  35. xradio/measurement_set/schema.py +122 -132
  36. xradio/schema/check.py +95 -101
  37. xradio/schema/dataclass.py +159 -22
  38. xradio/schema/export.py +99 -0
  39. xradio/schema/metamodel.py +51 -16
  40. xradio/schema/typing.py +5 -5
  41. xradio/sphinx/schema_table.py +41 -77
  42. {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/METADATA +20 -5
  43. xradio-0.0.59.dist-info/RECORD +65 -0
  44. {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/WHEEL +1 -1
  45. xradio/image/_util/fits.py +0 -13
  46. xradio/measurement_set/_utils/_msv2/_tables/load.py +0 -66
  47. xradio/measurement_set/_utils/_msv2/_tables/load_main_table.py +0 -490
  48. xradio/measurement_set/_utils/_msv2/_tables/read_subtables.py +0 -398
  49. xradio/measurement_set/_utils/_msv2/_tables/write.py +0 -323
  50. xradio/measurement_set/_utils/_msv2/_tables/write_exp_api.py +0 -388
  51. xradio/measurement_set/_utils/_msv2/chunks.py +0 -115
  52. xradio/measurement_set/_utils/_msv2/descr.py +0 -165
  53. xradio/measurement_set/_utils/_msv2/msv2_msv3.py +0 -7
  54. xradio/measurement_set/_utils/_msv2/partitions.py +0 -392
  55. xradio/measurement_set/_utils/_utils/cds.py +0 -40
  56. xradio/measurement_set/_utils/_utils/xds_helper.py +0 -404
  57. xradio/measurement_set/_utils/_zarr/read.py +0 -263
  58. xradio/measurement_set/_utils/_zarr/write.py +0 -329
  59. xradio/measurement_set/_utils/msv2.py +0 -106
  60. xradio/measurement_set/_utils/zarr.py +0 -133
  61. xradio-0.0.56.dist-info/RECORD +0 -78
  62. {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/licenses/LICENSE.txt +0 -0
  63. {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/top_level.txt +0 -0
@@ -46,16 +46,20 @@ def convert_casacore_time(
46
46
  rawtimes: np.ndarray, convert_to_datetime: bool = True
47
47
  ) -> np.ndarray:
48
48
  """
49
- Read time columns to datetime format
50
- pandas datetimes are referenced against a 0 of 1970-01-01
51
- CASA's modified julian day reference time is (of course) 1858-11-17
49
+ Convert data from casacore time columns to a different format, either:
50
+ a) pandas style datetime,
51
+ b) simply seconds from 1970-01-01 00:00:00 UTC (as used in the Unix scale of
52
+ astropy).
53
+
54
+ Pandas datetimes and Unix times are referenced against a 0 of 1970-01-01.
55
+ CASA's (casacore) modified julian day reference time is (of course) 1858-11-17.
52
56
 
53
57
  This requires a correction of 3506716800 seconds which is hardcoded to save time
54
58
 
55
59
  Parameters
56
60
  ----------
57
61
  rawtimes : np.ndarray
58
- times in casacore ref
62
+ time values wrt casacore reference
59
63
  convert_to_datetime : bool (Default value = True)
60
64
  whether to produce pandas style datetime
61
65
 
@@ -351,70 +355,6 @@ def add_units_measures(
351
355
  return mvars
352
356
 
353
357
 
354
- def make_freq_attrs(spw_xds: xr.Dataset, spw_id: int) -> Dict[str, Any]:
355
- """
356
- Grab the units/measure metainfo for the xds.freq dimension of a
357
- parttion from the SPECTRAL_WINDOW subtable CTDS attributes.
358
-
359
- Has to read xds_spw.meas_freq_ref and use it as index in the CTDS
360
- 'VarRefCol' attrs of CHAN_FREQ and REF_FREQUENCY to give a
361
- reference frame to xds_spw.ref_frequency and xds_spw.chan_freq
362
- (then the ref frame from the second will be pulled to
363
- xds.freq.attrs)
364
-
365
- Parameters
366
- ----------
367
- spw_xds : xr.Dataset
368
- (metainfo) SPECTRAL_WINDOW xds
369
- spw_id : int
370
- SPW id of a partition
371
-
372
- Returns
373
- -------
374
- Dict[str, Any]
375
- attributes (units/measure) for the freq dim of a partition
376
- """
377
- fallback_TabRefTypes = [
378
- "REST",
379
- "LSRK",
380
- "LSRD",
381
- "BARY",
382
- "GEO",
383
- "TOPO",
384
- "GALACTO",
385
- "LGROUP",
386
- "CMB",
387
- ]
388
-
389
- ctds_cols = spw_xds.attrs["other"]["msv2"]["ctds_attrs"]["column_descriptions"]
390
- cfreq = ctds_cols["CHAN_FREQ"]
391
-
392
- cf_attrs = spw_xds.data_vars["CHAN_FREQ"].attrs
393
- if "MEASINFO" in cfreq["keywords"] and "VarRefCol" in cfreq["keywords"]["MEASINFO"]:
394
- fattrs = cfreq["keywords"]["MEASINFO"]
395
- var_ref_col = fattrs["VarRefCol"]
396
- # This should point to the SPW/MEAS_FREQ_REF col
397
- meas_freq_ref_idx = spw_xds.data_vars[var_ref_col].values[spw_id]
398
-
399
- if "TabRefCodes" not in fattrs or "TabRefTypes" not in fattrs:
400
- # Datasets like vla/ic2233_1.ms say "VarRefCol" but "TabRefTypes" is missing
401
- ref_frame = fallback_TabRefTypes[meas_freq_ref_idx]
402
- else:
403
- ref_type_code = fattrs["TabRefCodes"][meas_freq_ref_idx]
404
- ref_frame = fattrs["TabRefTypes"][ref_type_code]
405
-
406
- cf_attrs["measure"] = {
407
- "type": fattrs["type"],
408
- "ref_frame": ref_frame,
409
- }
410
-
411
- # Also set the 'VarRefCol' for CHAN_FREQ and REF_FREQUENCEY
412
- spw_xds.data_vars["CHAN_FREQ"].attrs.update(cf_attrs)
413
- spw_xds.data_vars["REF_FREQUENCY"].attrs.update(cf_attrs)
414
-
415
- return cf_attrs
416
-
417
-
418
358
  def redimension_ms_subtable(xds: xr.Dataset, subt_name: str) -> xr.Dataset:
419
359
  """
420
360
  Expand a MeasurementSet subtable xds from single dimension (row)
@@ -551,8 +491,8 @@ def load_generic_table(
551
491
  tname : str
552
492
  (sub)table name, for example 'SOURCE' for myms.ms/SOURCE
553
493
  timecols : Union[List[str], None] (Default value = None)
554
- column names to convert to numpy datetime format.
555
- leaves times as their original casacore format.
494
+ Names of time column(s), to convert from casacore times to 1970-01-01 scale
495
+ An empty list leaves times as their original casacore format.
556
496
  ignore : Union[List[str], None] (Default value = None)
557
497
  list of column names to ignore and not try to read.
558
498
  rename_ids : Dict[str, str] (Default value = None)
@@ -748,7 +688,7 @@ def load_generic_cols(
748
688
  tb_tool : tables.table
749
689
  table to load the columns
750
690
  timecols : Union[List[str], None]
751
- columns names to convert to datetime format
691
+ column names to convert from casacore time format
752
692
  ignore : Union[List[str], None]
753
693
  list of column names to skip and not try to load.
754
694
 
@@ -828,7 +768,7 @@ def load_fixed_size_cols(
828
768
  tb_tool : tables.table
829
769
  table to red the columns
830
770
  timecols : Union[List[str], None]
831
- columns names to convert to datetime format
771
+ column names to convert from casacore time format
832
772
  ignore : Union[List[str], None]
833
773
  list of column names to skip and not try to load.
834
774
 
@@ -923,7 +863,8 @@ def raw_col_data_to_coords_vars(
923
863
  data: np.ndarray :
924
864
  column data
925
865
  timecols: Union[List[str], None]
926
- columns to be treated as TIME-related
866
+ columns to be treated as TIME-related (they are coordinate, need conversion from
867
+ casacore time format.
927
868
 
928
869
  Returns
929
870
  -------
@@ -953,7 +894,7 @@ def raw_col_data_to_coords_vars(
953
894
  data = convert_mjd_time(data).astype("float64") / 1e9
954
895
  else:
955
896
  try:
956
- data = convert_casacore_time(data)
897
+ data = convert_casacore_time(data, False)
957
898
  except pd.errors.OutOfBoundsDatetime as exc:
958
899
  if inpath.endswith("WEATHER"):
959
900
  # intentionally not callling logging.exception
@@ -993,7 +934,7 @@ def raw_col_data_to_coords_vars(
993
934
 
994
935
  def get_pad_value_in_tablerow_column(trows: tables.tablerow, col: str) -> object:
995
936
  """
996
- Gets the pad value for the type of a column (IMPORTANTLY) as froun in the
937
+ Gets the pad value for the type of a column (IMPORTANTLY) as found in the
997
938
  the type specified in the row / column value dict returned by tablerow.
998
939
  This can differ from the type of the column as given in the casacore
999
940
  column descriptions. See https://github.com/casangi/xradio/issues/242.
@@ -1195,7 +1136,7 @@ def read_col_chunk(
1195
1136
  np.ndarray
1196
1137
  """
1197
1138
  # TODO: consider calling load_col_chunk() from inside the withs
1198
- # for read_delayed_pointing_table and read_expanded_main_table
1139
+ # for read_expanded_main_table
1199
1140
  with open_table_ro(infile) as mtable:
1200
1141
  with open_query(mtable, ts_taql) as query:
1201
1142
  if (len(cshape) == 2) or (col == "UVW"): # all the scalars and UVW