Skip to content

Commit

Permalink
split gamma diffuse in train test with new child configs
Browse files Browse the repository at this point in the history
  • Loading branch information
vuillaut committed Sep 3, 2024
1 parent a7ddf5f commit 8e8da0e
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions lstmcpipe/config/paths_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def r0_to_dl1(self):
return paths

def training_merged_dl1(self, particle):
return os.path.join(self.dl1_dir(particle, ''), f'dl1_{self.prod_id}_{self.dec}_{particle}_merged.h5')
return os.path.join(self.dl1_dir(particle, ''), f'dl1_{self.prod_id}_train_{self.dec}_{particle}_merged.h5')

@property
def merge_dl1(self):
Expand Down Expand Up @@ -659,6 +659,29 @@ def train_pipe(self):
return paths



class PathConfigAllSkyTrainingWithSplit(PathConfigAllSkyTraining):
def __init__(self, prod_id, dec):
super().__init__(prod_id, dec)
self.stages.insert(1, 'train_test_split')

def dl1_diffuse_test_dir(self, pointing):
return self.dl1_dir('GammaDiffuse', pointing).replace('TrainingDataset', 'TestingDataset') + '/test'

def dl1_diffuse_train_dir(self, pointing):
return self.dl1_dir('GammaDiffuse', pointing) + '/train'

@property
def train_test_split(self):
paths = []
for pointing in self.pointing_dirs('GammaDiffuse'):
dl1 = self.dl1_dir('GammaDiffuse', pointing)
train = self.dl1_diffuse_train_dir(pointing)
test = self.dl1_diffuse_test_dir(pointing)
paths.append({'input': dl1, 'output': {'train': train, 'test': test}, 'options': {'test_size': 0.5}})
return paths


class PathConfigAllSkyTesting(PathConfigAllSkyBase):
def __init__(self, prod_id, dec):
super().__init__(prod_id, dec)
Expand Down Expand Up @@ -779,7 +802,7 @@ def r0_to_dl1(self):
return paths

def testing_merged_dl1(self, pointing):
return os.path.join(self.dl1_dir(''), f'dl1_{self.prod_id}_{pointing}_merged.h5')
return os.path.join(self.dl1_dir(''), f'dl1_{self.prod_id}_test_{pointing}_merged.h5')

@property
def merge_dl1(self):
Expand Down Expand Up @@ -831,6 +854,30 @@ def dl2_to_irfs(self):
return paths


class PathConfigAllSkyTestingWithSplit(PathConfigAllSkyTesting):
def __init__(self, prod_id, dec):
super().__init__(prod_id, dec)
# self.stages.insert(1, 'train_test_split')
self.train_config = PathConfigAllSkyTrainingWithSplit(prod_id, dec)

@property
def merge_dl1(self):
paths = []
for pointing in self.pointing_dirs():
dl1 = self.dl1_dir(pointing)
merged_dl1 = self.testing_merged_dl1(pointing)
paths.append({'input': dl1, 'output': merged_dl1, 'options': '--no-image'})
return paths

@property
def merge_diffuse(self):
paths = []
for pointing in self.train_config.pointing_dirs('GammaDiffuse'):
dl1 = self.train_config.dl1_diffuse_test_dir(pointing)
merged_dl1 = self.testing_merged_dl1(pointing)
paths.append({'input': dl1, 'output': merged_dl1, 'options': '--no-image'})
return paths

class PathConfigAllSkyFull(PathConfig):
def __init__(self, prod_id, dec_list):
"""
Expand Down

0 comments on commit 8e8da0e

Please sign in to comment.