cngi._utils._join_split

apply_coord_remap(xds: xarray.Dataset, coord_name: str, map_func)xarray.Dataset[source]

Apply the map_func to the values in the given coordinate

apply_data_var_remap(xds: xarray.Dataset, var_name: str, map_func)xarray.Dataset[source]

Apply the map_func to the values in the given data_var

get_subtable_dimcoords_or_primcoords(sub: xarray.Dataset, subtable_name: str)List[str][source]

Get the dimension coordinate and primary key coordinate names from the given subtable

append_xds_subtable(sub0: xarray.Dataset, sub1: xarray.Dataset)xarray.Dataset[source]

!!!COMPUTES!!! Append the given subtable sub1 to a new subtable based on sub0. pseudocode: ret = sub0.append(sub1)

Append sub1 to sub0 and return the result. Before appending sub1: 1. calculate new dimensional coordinate values for sub1 so that sub1 and sub0 DCs won’t conflict 2. apply DC changes to sub1_copy 3. apply the maps in relation_ids_map to the coordinates/data_vars in sub1_copy Finally, sub0 and sub1_copy are merged and returned.

Parameters
  • sub0 (xarray.Dataset) – the primary subtable to be copied and used as the base for the returned value

  • sub1 (xarray.Dataset) – the subtable to append to sub0

Returns

A new subtable, which the intention that it will be used to replace the current subtable in sub0.

Return type

xarray.Dataset

append_mxds_subtables(mxds0: xarray.Dataset, mxds1: xarray.Dataset, matchtype='exact')Tuple[xarray.Dataset, Dict[str, dict]][source]

!!!COMPUTES!!! Append the subtables of dataset mxds1 to the dataset mxds0 and return the new dataset.

pseudocode: ret = mxds0.append(mxds1.coords).append(mxds1.attrs.sel(!”xds*”))

This function makes heavy use of _remap_subtable_coords_and_vals to update references from mxds1 to mxds0 in a sort of round-robin style. The resulting subtables are merged into a new mxds to be returned.

The new mxds maintains all dims and coords of mxds0, with possibly expanded values for the dimensional coordinates.

If a subtable or coordinate appears in mxds1 that isn’t in mxds0, it is included in the returned result.

Parameters
  • mxds0 (xarray.Dataset) – The dataset to copy and append to.

  • mxds1 (xarray.Dataset) – The dataset to source new subtables from to append to the subtables in mxds0.

  • matchtype (str) – How to determine dimension coordinate equality. Dimcoord value equality is then used to determine which mxds1 coordinate and data_var values need to be remapped to new coordinates and merged, and which values can be safely ignored in the merge. See _get_subtable_matching_dimcoords() for a description of possible values.

Returns

  • xarray.Dataset – mxds0, plut the the appended subtables from mxds1.

  • dict – Map of which dimensional coordinates/primary keys were changed and their changed values. Keys are the names of the dimcoords/primekeys. Values are the mapping from old value in mxds1 to the new values in the returned dataset.

gen_keyname_variants(keyname: str)List[str][source]

The dimensional coordinate names and primary coordinate names from the mxds subtables are mangled in their usage in the main xds visibility tables. This function provides all possible mangled versions that can be matched against for doing comparisons.

Example keynames: antenna_id, beam_id, feed_id, spectral_window_id, ns_ws_station_id Example variants: “pol_id”, “spw_id”, “ANTENNA1”, “ANTENNA2”, “ARRAY_ID”, “FEED1”