Skip to content

Commit

Permalink
update calibration class following COntainers changes
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume.grolleron committed Sep 15, 2023
1 parent f5d0180 commit f1c3298
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/nectarchain/makers/calibration/gain/FlatFieldSPEMakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@

from .gainMakers import GainMaker

from ....data.container import ChargeContainer
from ....data.container import ChargesContainer

from ...chargesMakers import ChargesMaker

from .parameters import Parameter, Parameters

Expand Down Expand Up @@ -280,13 +282,13 @@ def __init__(self,charge,counts,*args,**kwargs) -> None:
self._results.add_column(Column(np.zeros((self.npixels),dtype = np.float64),"pvalue",unit = u.dimensionless_unscaled))

@classmethod
def create_from_chargeContainer(cls, signal : ChargeContainer,**kwargs) :
histo = signal.histo_hg(autoscale = True)
def create_from_chargesContainer(cls, signal : ChargesContainer,**kwargs) :
histo = ChargesMaker.histo_hg(signal,autoscale = True)
return cls(charge = histo[1],counts = histo[0],pixels_id = signal.pixels_id,**kwargs)

@classmethod
def create_from_run_number(cls, run_number : int, **kwargs) :
raise NotImplementedError()
raise NotImplementedError("Need to implement here the use of the WaveformsMaker and ChargesMaker to produce the chargesContainer to be pass into the __ini__")

#getters and setters
@property
Expand Down
22 changes: 12 additions & 10 deletions src/nectarchain/makers/calibration/gain/PhotoStatisticMakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

from ctapipe_io_nectarcam import constants

from ....data.container import ChargeContainer
from ....data.container import ChargesContainer,ChargesContainerIO

from ...chargesMakers import ChargesMaker

from .gainMakers import GainMaker

Expand Down Expand Up @@ -64,8 +66,8 @@ def __init__(self,

@classmethod
def create_from_chargeContainer(cls,
FFcharge : ChargeContainer,
Pedcharge : ChargeContainer,
FFcharge : ChargesContainer,
Pedcharge : ChargesContainer,
coefCharge_FF_Ped,
SPE_resolution,
**kwargs) :
Expand Down Expand Up @@ -99,7 +101,7 @@ def __readSPE(SPEresults) :
return table['resolution'][table['is_valid']].value,table['pixels_id'][table['is_valid']].value

@staticmethod
def __get_charges_FF_Ped_reshaped( FFcharge : ChargeContainer, Pedcharge : ChargeContainer, SPE_resolution, SPE_pixels_id) :
def __get_charges_FF_Ped_reshaped( FFcharge : ChargesContainer, Pedcharge : ChargesContainer, SPE_resolution, SPE_pixels_id) :
log.info("reshape of SPE, Ped and FF data with intersection of pixel ids")
out = {}

Expand All @@ -110,10 +112,10 @@ def __get_charges_FF_Ped_reshaped( FFcharge : ChargeContainer, Pedcharge : Charg
out["SPE_resolution"] = SPE_resolution[mask_SPE]

out["pixels_id"] = SPEFFPed_intersection
out["FFcharge_hg"] = FFcharge.select_charge_hg(SPEFFPed_intersection)
out["FFcharge_lg"] = FFcharge.select_charge_lg(SPEFFPed_intersection)
out["Pedcharge_hg"] = Pedcharge.select_charge_hg(SPEFFPed_intersection)
out["Pedcharge_lg"] = Pedcharge.select_charge_lg(SPEFFPed_intersection)
out["FFcharge_hg"] = ChargesMaker.select_charges_hg(FFcharge,SPEFFPed_intersection)
out["FFcharge_lg"] = ChargesMaker.select_charges_lg(FFcharge,SPEFFPed_intersection)
out["Pedcharge_hg"] = ChargesMaker.select_charges_hg(Pedcharge,SPEFFPed_intersection)
out["Pedcharge_lg"] = ChargesMaker.select_charges_lg(Pedcharge,SPEFFPed_intersection)

log.info(f"data have {len(SPEFFPed_intersection)} pixels in common")
return out
Expand All @@ -134,7 +136,7 @@ def __readFF(FFRun,**kwargs) :
coefCharge_FF_Ped = 1
if isinstance(FFRun,int) :
try :
FFcharge = ChargeContainer.from_file(f"{os.environ['NECTARCAMDATA']}/charges/{method}",FFRun)
FFcharge = ChargesContainerIO.load(f"{os.environ['NECTARCAMDATA']}/charges/{method}",FFRun)
log.info(f'charges have ever been computed for FF run {FFRun}')
except Exception as e :
log.error("charge have not been yet computed")
Expand All @@ -151,7 +153,7 @@ def __readPed(PedRun,**kwargs) :
method = 'FullWaveformSum'#kwargs.get('method','std')
if isinstance(PedRun,int) :
try :
Pedcharge = ChargeContainer.from_file(f"{os.environ['NECTARCAMDATA']}/charges/{method}",PedRun)
Pedcharge = ChargesContainerIO.load(f"{os.environ['NECTARCAMDATA']}/charges/{method}",PedRun)
log.info(f'charges have ever been computed for Ped run {PedRun}')
except Exception as e :
log.error("charge have not been yet computed")
Expand Down
2 changes: 1 addition & 1 deletion src/nectarchain/makers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ..data import DataManagement
from ..data.container.core import ArrayDataContainer

__all__ = ["BaseMaker"]
__all__ = ["ArrayDataMaker"]

class BaseMaker(ABC):
"""Mother class for all the makers, the role of makers is to do computation on the data.
Expand Down

0 comments on commit f1c3298

Please sign in to comment.