-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add factory methods to enable gain jones matrix.
- Loading branch information
Showing
8 changed files
with
84 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"CalibrationMatrix.create_jones": { | ||
"factory": { | ||
"nullable": false, | ||
"required": true, | ||
"type": [ | ||
"string" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"GainMatrixDataset": "calviper.factory.gain" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
import pathlib | ||
import json | ||
import importlib | ||
|
||
import toolviper.utils.logger as logger | ||
|
||
def register_subclass(cls): | ||
""" | ||
There will be a lot more added here bt for testing ..... | ||
""" | ||
import importlib | ||
|
||
if cls.__name__ == "GainMatrixDataSet": | ||
importlib.import_module("calviper.factory.gain") | ||
config_path = str(pathlib.Path(__file__).parent.parent.joinpath("config").joinpath("subclasses.config.json").resolve()) | ||
|
||
with open(config_path, "r") as file: | ||
object_ = json.load(file) | ||
if cls.__name__ in object_: | ||
importlib.import_module(object_[cls.__name__]) | ||
|
||
else: | ||
logger.error(f"No subclass named {cls.__name__}") | ||
|
||
|
||
return cls | ||
|
||
return cls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
from abc import ABC | ||
|
||
import numpy as np | ||
import xarray as xr | ||
|
||
import calviper.math.tools as tools | ||
import toolviper.utils.logger as logger | ||
|
||
from calviper.factory.base import JonesMatrix | ||
from typing import TypeVar, Type, Union | ||
|
||
T = TypeVar('T', bound='Parent') | ||
|
||
|
||
@xr.register_dataset_accessor("gain") | ||
class GainMatrix: | ||
class GainMatrix(JonesMatrix, ABC): | ||
def __init__(self, dataset: xr.Dataset): | ||
super(GainMatrix, self).__init__() | ||
self._object = dataset | ||
|
||
self.type: str = "G" | ||
self.dtype: Type = np.complex64 | ||
self.channel_dependent_parameters: bool = False | ||
|
||
self._matrix: Union[None, np.ndarray] = None | ||
|
||
@property | ||
def data(self): | ||
return self._object | ||
return self._object | ||
|
||
@property | ||
def matrix(self) -> np.ndarray: | ||
return self._matrix | ||
|
||
@matrix.setter | ||
def matrix(self, array: np.ndarray) -> None: | ||
# (self.n_times, self.n_baselines, self.n_channels, _, _) = array.shape | ||
|
||
# There should be a check on the shape here. I don't think we want to allow, for instance, | ||
# an axis to be averaged while also having the dimensions stored in the object not change. | ||
self._matrix = array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters