pspipe 0.8__tar.gz → 0.9__tar.gz

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 (32) hide show
  1. {pspipe-0.8 → pspipe-0.9}/PKG-INFO +9 -1
  2. {pspipe-0.8 → pspipe-0.9}/pspipe/database.py +44 -34
  3. {pspipe-0.8 → pspipe-0.9}/pspipe/obsdata.py +21 -17
  4. {pspipe-0.8 → pspipe-0.9}/pspipe/settings.py +11 -9
  5. {pspipe-0.8 → pspipe-0.9}/pspipe/tasks.py +140 -96
  6. {pspipe-0.8 → pspipe-0.9}/pspipe/tools/psdb.py +37 -29
  7. {pspipe-0.8 → pspipe-0.9}/pspipe/tools/pspipe.py +5 -5
  8. {pspipe-0.8 → pspipe-0.9}/pspipe/utils.py +11 -10
  9. {pspipe-0.8 → pspipe-0.9}/pyproject.toml +36 -7
  10. {pspipe-0.8 → pspipe-0.9}/LICENSE +0 -0
  11. {pspipe-0.8 → pspipe-0.9}/README.md +0 -0
  12. {pspipe-0.8 → pspipe-0.9}/pspipe/__init__.py +0 -0
  13. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/eor_bins_a12.parset +0 -0
  14. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/eor_bins_alo.parset +0 -0
  15. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/eor_bins_hba.parset +0 -0
  16. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/eor_bins_nenufar.parset +0 -0
  17. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/flagger.parset +0 -0
  18. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/flagger_pre_combine.parset +0 -0
  19. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/gpr_config_a12.parset +0 -0
  20. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/gpr_config_hba.parset +0 -0
  21. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/gpr_config_nenufar.parset +0 -0
  22. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/gpr_config_v.parset +0 -0
  23. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/ps_config_a12.parset +0 -0
  24. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/ps_config_alo.parset +0 -0
  25. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/ps_config_hba.parset +0 -0
  26. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/config/ps_config_nenufar.parset +0 -0
  27. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/default_a12.toml +0 -0
  28. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/default_alo.toml +0 -0
  29. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/default_hba.toml +0 -0
  30. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/default_nenufar.toml +0 -0
  31. {pspipe-0.8 → pspipe-0.9}/pspipe/templates/default_settings.toml +0 -0
  32. {pspipe-0.8 → pspipe-0.9}/pspipe/tools/__init__.py +0 -0
@@ -1,7 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pspipe
3
- Version: 0.8
3
+ Version: 0.9
4
4
  Summary: Power spectra pipeline for Cosmic Dawn, Epoch of Reionization radio interferometric experiments
5
+ License-Expression: GPL-3.0-or-later
5
6
  License-File: LICENSE
6
7
  Author: Florent Mertens
7
8
  Author-email: florent.mertens@gmail.com
@@ -12,16 +13,23 @@ Classifier: Programming Language :: Python :: 3.11
12
13
  Classifier: Programming Language :: Python :: 3.12
13
14
  Classifier: Programming Language :: Python :: 3.13
14
15
  Classifier: Programming Language :: Python :: 3.14
16
+ Provides-Extra: dev
15
17
  Provides-Extra: ml-gpr
16
18
  Requires-Dist: astropy (>6.0)
17
19
  Requires-Dist: click (>=8.0)
18
20
  Requires-Dist: libpipe (>=0.6)
19
21
  Requires-Dist: ps-eor (>=0.8)
20
22
  Requires-Dist: ps-eor[ml-gpr] (>=0.8) ; extra == "ml-gpr"
23
+ Requires-Dist: pytest (>=8.0) ; extra == "dev"
24
+ Requires-Dist: pytest-cov (>=5.0) ; extra == "dev"
21
25
  Requires-Dist: python-casacore (>=3.0)
26
+ Requires-Dist: ruff (==0.16.1) ; extra == "dev"
22
27
  Requires-Dist: tables (>=3.2)
23
28
  Requires-Dist: tabulate (>=0.8)
24
29
  Requires-Dist: toml (>=0.10)
30
+ Project-URL: Homepage, https://gitlab.com/flomertens/pspipe
31
+ Project-URL: Issues, https://gitlab.com/flomertens/pspipe/-/issues
32
+ Project-URL: Repository, https://gitlab.com/flomertens/pspipe
25
33
  Description-Content-Type: text/markdown
26
34
 
27
35
  Power Spectra Generation pipeline for CD/EoR experiments
@@ -2,24 +2,22 @@
2
2
  #
3
3
  # Author: F. Mertens
4
4
 
5
- import os
6
- import hashlib
5
+ import fnmatch
7
6
  import glob
7
+ import hashlib
8
8
  import json
9
- import fnmatch
9
+ import os
10
10
  from collections import OrderedDict
11
11
 
12
12
  import numpy as np
13
-
14
- from libpipe import attrmap
15
- from libpipe import futils
13
+ from libpipe import attrmap, futils
16
14
  from libpipe.attrmap import OrderedSet
17
15
 
16
+ from . import utils
17
+
18
18
  # Lazy loaded:
19
19
  # - .obsdata.ObsData in VisRevision.get_data()
20
-
21
20
  from .settings import Settings
22
- from . import utils
23
21
 
24
22
  OBS_ID_JSON_POSTFIX = '_obs_id.json'
25
23
  IMG_REV_JSON = 'img_list.json'
@@ -49,25 +47,28 @@ def get_type_name(stokes_or_psf, even, odd):
49
47
  def listdir_isdir(path, ignore=None):
50
48
  if not os.path.exists(path):
51
49
  return []
52
- return [f for f in os.listdir(path) if os.path.isdir(os.path.join(path, f)) and not f.startswith('.') and
53
- (ignore is None or f not in ignore)]
50
+ return [f for f in os.listdir(path)
51
+ if os.path.isdir(os.path.join(path, f)) and not f.startswith('.')
52
+ and (ignore is None or f not in ignore)]
54
53
 
55
54
 
56
- class Database(object):
55
+ class Database:
57
56
 
58
57
  def __init__(self, settings_obj):
59
58
  self.settings = settings_obj
60
59
 
61
60
  def list_obs_ids(self):
62
- files = glob.glob(os.path.join(self.settings.get_path('data_dir'), 'obs_ids', f'*{OBS_ID_JSON_POSTFIX}'))
61
+ files = glob.glob(os.path.join(self.settings.get_path('data_dir'), 'obs_ids',
62
+ f'*{OBS_ID_JSON_POSTFIX}'))
63
63
  return [os.path.basename(k).split(OBS_ID_JSON_POSTFIX)[0] for k in files]
64
64
 
65
65
  def filter_obs_ids(self, obs_id_str):
66
66
  all_obs_ids = self.list_obs_ids()
67
- return set(obs_id for k in obs_id_str.split(',') for obs_id in fnmatch.filter(all_obs_ids, k))
67
+ return {obs_id for k in obs_id_str.split(',') for obs_id in fnmatch.filter(all_obs_ids, k)}
68
68
 
69
69
  def get_obs_id_meta_path(self, obs_id):
70
- return os.path.join(self.settings.get_path('data_dir'), 'obs_ids', obs_id + OBS_ID_JSON_POSTFIX)
70
+ return os.path.join(self.settings.get_path('data_dir'), 'obs_ids',
71
+ obs_id + OBS_ID_JSON_POSTFIX)
71
72
 
72
73
  def get_obs_id_meta(self, obs_id):
73
74
  obs_id_meta_file = self.get_obs_id_meta_path(obs_id)
@@ -108,7 +109,8 @@ class Database(object):
108
109
 
109
110
  def list_image_revisions(self):
110
111
  return [ImageRevision(Settings.load_with_defaults(k))
111
- for k in glob.glob(os.path.join(self.settings.get_path('data_dir'), '*', IMG_REV_TOML))]
112
+ for k in glob.glob(os.path.join(self.settings.get_path('data_dir'), '*',
113
+ IMG_REV_TOML))]
112
114
 
113
115
  def get_image_revision(self, img_rev_name=None):
114
116
  img_rev_conf_file = ImageRevision(self.settings, img_rev_name).get_settings_path()
@@ -130,7 +132,7 @@ class Database(object):
130
132
  os.remove(self.get_obs_id_meta_path(obs_id))
131
133
 
132
134
 
133
- class ImageRevision(object):
135
+ class ImageRevision:
134
136
 
135
137
  def __init__(self, settings_obj, img_rev_name=None):
136
138
  self.settings = settings_obj.copy()
@@ -188,8 +190,11 @@ class ImageRevision(object):
188
190
  obs_meta = Database(self.settings).get_obs_id_meta(obs_id)
189
191
  start, end, interval = self.settings.image.lst_bins
190
192
 
191
- s2day = lambda sec: sec / 3600. / 24.
192
- hr2int = lambda hr: int(hr * 3600. / obs_meta.int_time)
193
+ def s2day(sec):
194
+ return sec / 3600. / 24.
195
+
196
+ def hr2int(hr):
197
+ return int(hr * 3600. / obs_meta.int_time)
193
198
 
194
199
  start_lst = utils.get_lst(s2day(obs_meta.start_time), self.settings.longitude)
195
200
  end_lst = utils.get_lst(s2day(obs_meta.end_time), self.settings.longitude)
@@ -199,7 +204,8 @@ class ImageRevision(object):
199
204
  bin_int = hr2int(interval)
200
205
 
201
206
  for i, (s, e) in enumerate(utils.pairwise(np.arange(start, end + interval, interval))):
202
- if utils.is_in_lst_bin(s, start_lst, end_lst) and utils.is_in_lst_bin(e, start_lst, end_lst):
207
+ if (utils.is_in_lst_bin(s, start_lst, end_lst)
208
+ and utils.is_in_lst_bin(e, start_lst, end_lst)):
203
209
  lst_bins[i] = [s, e]
204
210
  if utils.is_in_lst_bin(start_lst, s, e):
205
211
  start_index = hr2int(abs(e - start_lst))
@@ -209,7 +215,8 @@ class ImageRevision(object):
209
215
 
210
216
  if return_time_index:
211
217
  lst_idx = lst_bins.keys()
212
- data_lst_idx = np.arange(start_lst_idx + 1, start_lst_idx + 1 + len(lst_idx)) % (max(lst_idx) + 1)
218
+ data_lst_idx = np.arange(start_lst_idx + 1,
219
+ start_lst_idx + 1 + len(lst_idx)) % (max(lst_idx) + 1)
213
220
 
214
221
  return lst_bins, (start_index, end_index, bin_int), data_lst_idx
215
222
 
@@ -240,14 +247,15 @@ class ImageRevision(object):
240
247
 
241
248
  def filter_obs_ids(self, obs_id_str):
242
249
  all_obs_ids = self.list_obs_ids()
243
- return set(obs_id for k in obs_id_str.split(',') for obs_id in fnmatch.filter(all_obs_ids, k))
250
+ return {obs_id for k in obs_id_str.split(',') for obs_id in fnmatch.filter(all_obs_ids, k)}
244
251
 
245
252
  def has_obs_id(self, obs_id):
246
253
  return obs_id in self.list_obs_ids()
247
254
 
248
255
  def new_obs_id(self, obs_id, lst_idx=None, data_dir_root=None):
249
- img_meta = ImageRevisionMeta.new(self.get_meta_path(obs_id, lst_idx=lst_idx), obs_id, self.settings.image.name,
250
- data_dir_root=data_dir_root)
256
+ img_meta = ImageRevisionMeta.new(
257
+ self.get_meta_path(obs_id, lst_idx=lst_idx), obs_id, self.settings.image.name,
258
+ data_dir_root=data_dir_root)
251
259
  os.makedirs(os.path.dirname(self.get_meta_path(obs_id, lst_idx=lst_idx)), exist_ok=True)
252
260
  img_meta.save()
253
261
 
@@ -286,7 +294,7 @@ class ImageRevision(object):
286
294
  futils.rm_if_exist(self.get_path())
287
295
 
288
296
 
289
- class VisRevision(object):
297
+ class VisRevision:
290
298
 
291
299
  def __init__(self, settings_obj, img_rev_name=None, **vis_kargs):
292
300
  self.settings = settings_obj.copy()
@@ -332,7 +340,7 @@ class VisRevision(object):
332
340
 
333
341
  def filter_obs_ids(self, obs_id_str):
334
342
  all_obs_ids = self.list_obs_ids()
335
- return set(obs_id for k in obs_id_str.split(',') for obs_id in fnmatch.filter(all_obs_ids, k))
343
+ return {obs_id for k in obs_id_str.split(',') for obs_id in fnmatch.filter(all_obs_ids, k)}
336
344
 
337
345
  def has_obs_id(self, obs_id):
338
346
  return obs_id in self.list_obs_ids()
@@ -345,7 +353,8 @@ class VisRevision(object):
345
353
  return img_meta
346
354
 
347
355
  def get_lst_bins(self, obs_id, return_time_index=False):
348
- return ImageRevision(self.settings).get_lst_bins(obs_id, return_time_index=return_time_index)
356
+ return ImageRevision(self.settings).get_lst_bins(obs_id,
357
+ return_time_index=return_time_index)
349
358
 
350
359
  def get_meta(self, obs_id, lst_idx=None):
351
360
  meta_file = self.get_meta_path(obs_id, lst_idx=lst_idx)
@@ -397,7 +406,7 @@ class ObsIDMeta(AbstractJsonMeta):
397
406
 
398
407
  @staticmethod
399
408
  def new(file, obs_id, **kargs):
400
- assert utils.all_in_other(kargs, obs_id_info_keys + ['ms_files'])
409
+ assert utils.all_in_other(kargs, [*obs_id_info_keys, 'ms_files'])
401
410
 
402
411
  d = {'obs_id': obs_id, 'ms_files': []}
403
412
  d.update(dict.fromkeys(obs_id_info_keys, 0))
@@ -430,7 +439,7 @@ class ImageRevisionMeta(AbstractJsonMeta):
430
439
 
431
440
  def get_fits(self, stokes_or_psf, even=False, odd=False):
432
441
  assert (even != odd) or (even is False)
433
- assert stokes_or_psf in all_stokes + ['psf', None]
442
+ assert stokes_or_psf in [*all_stokes, 'psf', None]
434
443
 
435
444
  name = get_type_name(stokes_or_psf, even, odd)
436
445
 
@@ -443,14 +452,15 @@ class ImageRevisionMeta(AbstractJsonMeta):
443
452
  return get_type_name(stokes, even, odd) in self
444
453
 
445
454
  def get_all_stokes(self):
446
- return set(k.split('_')[0] for k in self if k.split('_')[0].upper() in all_stokes)
455
+ return {k.split('_')[0] for k in self if k.split('_')[0].upper() in all_stokes}
447
456
 
448
457
  def get_fits_stat(self):
449
- return dict((k, len(v)) for k, v in self.items() if isinstance(v, list) and len(v) > 0)
458
+ return {k: len(v) for k, v in self.items() if isinstance(v, list) and len(v) > 0}
450
459
 
451
- def add_fits(self, files, stokes_or_psf=None, even=False, odd=False, verbose=False, img_name='image'):
460
+ def add_fits(self, files, stokes_or_psf=None, even=False, odd=False, verbose=False,
461
+ img_name='image'):
452
462
  assert (even != odd) or (even is False)
453
- assert stokes_or_psf in all_stokes + ['psf', None]
463
+ assert stokes_or_psf in [*all_stokes, 'psf', None]
454
464
 
455
465
  if stokes_or_psf is not None:
456
466
  name = get_type_name(stokes_or_psf, even=even, odd=odd)
@@ -477,7 +487,7 @@ class ImageRevisionMeta(AbstractJsonMeta):
477
487
  i_files = fnmatch.filter(files, f'*{img_name}.fits')
478
488
  if i_files:
479
489
  self.add_fits(i_files, 'I', even=even, odd=odd, verbose=verbose)
480
- psf_files = fnmatch.filter(files, f'*psf.fits')
490
+ psf_files = fnmatch.filter(files, '*psf.fits')
481
491
  if psf_files:
482
492
  self.add_fits(psf_files, 'psf', even=even, odd=odd, verbose=verbose)
483
493
 
@@ -498,5 +508,5 @@ class VisRevisionMeta(AbstractJsonMeta):
498
508
  return get_type_name(stokes, even, odd) in self
499
509
 
500
510
  def get_all_stokes(self):
501
- return set(k.split('_')[0] for k in self if k.split('_')[0].upper() in all_stokes)
511
+ return {k.split('_')[0] for k in self if k.split('_')[0].upper() in all_stokes}
502
512
 
@@ -5,8 +5,7 @@
5
5
  import os
6
6
 
7
7
  import numpy as np
8
-
9
- from ps_eor import pspec, datacube, flagger
8
+ from ps_eor import datacube, flagger, pspec
10
9
 
11
10
  from . import database, utils
12
11
 
@@ -14,7 +13,7 @@ from . import database, utils
14
13
  # from ps_eor import ml_gpr
15
14
 
16
15
 
17
- class ObsData(object):
16
+ class ObsData:
18
17
 
19
18
  def __init__(self, vis_rev, obs_id, lst_idx=None):
20
19
  self.vis_rev = vis_rev
@@ -28,13 +27,13 @@ class ObsData(object):
28
27
  self.all_stokes = {}
29
28
  for stokes in database.all_stokes:
30
29
  self.all_stokes[stokes.lower()] = stokes
31
- self.all_stokes[stokes.lower() + '_even'] = 'even_%s' % stokes
32
- self.all_stokes[stokes.lower() + '_odd'] = 'odd_%s' % stokes
33
- self.all_stokes[stokes.lower() + '_dt'] = 'dt_%s' % stokes
30
+ self.all_stokes[stokes.lower() + '_even'] = f'even_{stokes}'
31
+ self.all_stokes[stokes.lower() + '_odd'] = f'odd_{stokes}'
32
+ self.all_stokes[stokes.lower() + '_dt'] = f'dt_{stokes}'
34
33
  self._ps_builder = None
35
34
 
36
35
  def __getattr__(self, key):
37
- assert key in self.all_stokes.keys()
36
+ assert key in self.all_stokes
38
37
  return self.get_stokes(self.all_stokes[key])
39
38
 
40
39
  def _invalidate_cache(self):
@@ -131,30 +130,35 @@ class ObsData(object):
131
130
  return stokes in self.data or os.path.exists(self.get_h5_file(stokes))
132
131
 
133
132
  def get_ml_gpr_path(self, eor_bin, umin=50, umax=250, name='', sampler_method='mcmc'):
134
- return os.path.join(os.path.dirname(self.get_h5_file('I')), name, f'eor{eor_bin}_u{umin}-{umax}')
133
+ return os.path.join(os.path.dirname(self.get_h5_file('I')), name,
134
+ f'eor{eor_bin}_u{umin}-{umax}')
135
135
 
136
136
  def get_ml_gpr_res(self, eor_bin, umin=50, umax=250, name='', sampler_method='mcmc'):
137
137
  from ps_eor import ml_gpr
138
138
 
139
- path = self.get_ml_gpr_path(eor_bin, umin=umin, umax=umax, name=name, sampler_method=sampler_method)
139
+ path = self.get_ml_gpr_path(eor_bin, umin=umin, umax=umax, name=name,
140
+ sampler_method=sampler_method)
140
141
  return ml_gpr.MLGPRResult.load(path, 'ml_gpr_res_I', sampler_method=sampler_method)
141
142
 
142
143
  def get_ml_gpr_inj_path(self, eor_bin, var_21_over_noise, x1, x2, umin=50, umax=250, name=''):
143
144
  d = f'inj_eor{eor_bin}_u{umin}-{umax}_a{var_21_over_noise:.3f}_x1{x1:.3f}_x2{x2:.3f}'
144
145
  return os.path.join(os.path.dirname(self.get_h5_file('I')), name, d)
145
146
 
146
- def get_ml_gpr_inj_res(self, eor_bin, var_21_over_noise, x1, x2, umin=50, umax=250, name='', sampler_method='mcmc'):
147
+ def get_ml_gpr_inj_res(self, eor_bin, var_21_over_noise, x1, x2, umin=50, umax=250, name='',
148
+ sampler_method='mcmc'):
147
149
  from ps_eor import ml_gpr
148
150
 
149
- path = self.get_ml_gpr_inj_path(eor_bin, var_21_over_noise=var_21_over_noise, x1=x1, x2=x2, umin=umin, umax=umax, name=name)
151
+ path = self.get_ml_gpr_inj_path(eor_bin, var_21_over_noise=var_21_over_noise, x1=x1, x2=x2,
152
+ umin=umin, umax=umax, name=name)
150
153
  data_inj = datacube.CartDataCube.load(os.path.join(path, 'c_injected.h5'))
151
- return ml_gpr.MLGPRInjResult.load(path, 'ml_gpr_res_I', data_inj, sampler_method=sampler_method)
154
+ return ml_gpr.MLGPRInjResult.load(path, 'ml_gpr_res_I', data_inj,
155
+ sampler_method=sampler_method)
152
156
 
153
157
  def get_ps_gen(self, **kargs):
154
158
  return self.ps_builder.get(self.get_stokes_i_like(), **kargs)
155
159
 
156
160
 
157
- class ObsDataGroup(object):
161
+ class ObsDataGroup:
158
162
  """A group of observations exposed through a combined ObsData-like view."""
159
163
 
160
164
  def __init__(self, observations, name, umin, umax, weighting_mode='full',
@@ -184,9 +188,9 @@ class ObsDataGroup(object):
184
188
  self.observation_weights = {
185
189
  obs_id: float(weight)
186
190
  for obs_id, weight in dict(observation_weights).items()}
187
- except (TypeError, ValueError):
191
+ except (TypeError, ValueError) as err:
188
192
  raise ValueError(
189
- 'observation_weights must contain real scalar values')
193
+ 'observation_weights must contain real scalar values') from err
190
194
  missing = set(obs_ids) - set(self.observation_weights)
191
195
  unknown = set(self.observation_weights) - set(obs_ids)
192
196
  if missing or unknown:
@@ -257,7 +261,7 @@ class ObsDataGroup(object):
257
261
 
258
262
  for obs, cube in zip(
259
263
  self.observations,
260
- self.get_observation_cubes(stokes)):
264
+ self.get_observation_cubes(stokes), strict=False):
261
265
  cube = cube.copy()
262
266
  if cube.weights is None:
263
267
  raise ValueError(
@@ -284,7 +288,7 @@ class ObsDataGroup(object):
284
288
  self.get_stokes_i_like(), **kargs)
285
289
 
286
290
 
287
- class ObsDataCollection(object):
291
+ class ObsDataCollection:
288
292
  """Observation groups indexed by contiguous LST bins."""
289
293
 
290
294
  def __init__(self, lst_bins, groups):
@@ -5,16 +5,13 @@
5
5
  import os
6
6
 
7
7
  import astropy.units as u
8
-
9
8
  from libpipe import futils
10
9
  from libpipe.settings import BaseSettings
11
10
 
12
11
  # Lazy loaded:
13
12
  # - ps_eor.datacube in Settings.validate_vis_cube()
14
-
15
13
  from . import utils
16
14
 
17
-
18
15
  TEMPLATE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
19
16
 
20
17
  TEMPLATE_NAMES = ['a12', 'nenufar', 'hba', 'alo']
@@ -29,7 +26,8 @@ class Settings(BaseSettings):
29
26
 
30
27
  def validate_image(self, val_fct):
31
28
  val_fct(u.Unit(self.image.scale).is_equivalent((u.rad, u.s)), 'scale')
32
- val_fct(len(self.image.size.split()) == 2 and all(k.isdigit() for k in self.image.size.split()), 'size')
29
+ val_fct(len(self.image.size.split()) == 2
30
+ and all(k.isdigit() for k in self.image.size.split()), 'size')
33
31
  val_fct(self.image.channels_out == 'all' or str(self.image.channels_out).startswith(
34
32
  'every') or utils.is_number(self.image.channels_out), 'channels_out')
35
33
  val_fct(isinstance(self.image.umin, (int, float)), 'umin')
@@ -40,7 +38,8 @@ class Settings(BaseSettings):
40
38
  val_fct(isinstance(self.image.time_end_index, int), 'time_end_index')
41
39
  if self.image.time_end_index or self.image.time_start_index:
42
40
  val_fct(self.image.time_end_index >= self.image.time_start_index, 'time_end_index')
43
- val_fct(isinstance(self.image.lst_bins, list) and len(self.image.lst_bins) in [0, 3], 'lst_bins')
41
+ val_fct(isinstance(self.image.lst_bins, list) and len(self.image.lst_bins) in [0, 3],
42
+ 'lst_bins')
44
43
  val_fct(isinstance(self.image.clean_niter, (int, float)), 'clean_niter')
45
44
  val_fct(isinstance(self.image.clean_auto_threshold, (int, float)), 'clean_auto_threshold')
46
45
  val_fct(isinstance(self.image.clean_mgain, (int, float)), 'clean_mgain')
@@ -59,7 +58,8 @@ class Settings(BaseSettings):
59
58
  val_fct(isinstance(self.merge_ms.time_start_index, int), 'time_start_index')
60
59
  val_fct(isinstance(self.merge_ms.time_end_index, int), 'time_end_index')
61
60
  if self.merge_ms.time_end_index or self.merge_ms.time_start_index:
62
- val_fct(self.merge_ms.time_end_index >= self.merge_ms.time_start_index, 'time_end_index')
61
+ val_fct(self.merge_ms.time_end_index >= self.merge_ms.time_start_index,
62
+ 'time_end_index')
63
63
 
64
64
  def validate_vis_cube(self, val_fct):
65
65
  from ps_eor import datacube
@@ -67,8 +67,9 @@ class Settings(BaseSettings):
67
67
  val_fct(isinstance(self.vis_cube.fov, (int, float, str)), 'fov')
68
68
  val_fct(isinstance(self.vis_cube.umin, (int, float)), 'umin')
69
69
  val_fct(isinstance(self.vis_cube.umax, (int, float)), 'umax')
70
- val_fct(len(datacube.get_window(datacube.WindowFunction.parse_winfct_str(self.vis_cube.win_fct), 3)) == 3,
71
- 'win_fct')
70
+ val_fct(len(datacube.get_window(
71
+ datacube.WindowFunction.parse_winfct_str(self.vis_cube.win_fct), 3)) == 3,
72
+ 'win_fct')
72
73
 
73
74
  def validate_vis_to_sph(self, val_fct):
74
75
  val_fct(futils.is_file(self.vis_to_sph.pre_flag), 'pre_flag')
@@ -103,6 +104,7 @@ class Settings(BaseSettings):
103
104
 
104
105
 
105
106
  def get_template_path(template_name):
106
- assert template_name in TEMPLATE_NAMES, f'template_name should be one of: {" ".join(TEMPLATE_NAMES)}'
107
+ assert template_name in TEMPLATE_NAMES, (f'template_name should be one of: '
108
+ f'{" ".join(TEMPLATE_NAMES)}')
107
109
 
108
110
  return os.path.join(TEMPLATE_DIR, f'default_{template_name}.toml')