-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsuncet_processor.py
53 lines (40 loc) · 1.92 KB
/
suncet_processor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
This is the main wrapper for most/all(?) of the other processor related python files. Those also inherit the common functionality of Processor.
"""
import os
from glob import glob
import pandas as pd
import astropy.units as u
import sunpy.map
from astropy.io import fits
from suncet_processing_pipeline import config_parser
from suncet_processing_pipeline.make_level0_5 import Level0_5
from suncet_processing_pipeline.make_level1 import Level1
class Processor:
def __init__(self, config_filename=None):
if config_filename is None:
raise ValueError('It is important that you specify a path/filename to the config file you want to run with. That is your main method of interacting with the procesing.')
self.config = self.__read_config(config_filename)
self.metadata = self.__load_metadata_definition()
def __read_config(self, config_filename):
return config_parser.Config(config_filename)
def __load_metadata_definition(self):
return pd.read_csv(os.getenv('suncet_data') + '/metadata/' + self.config.base_metadata_filename)
def save_metadata(self, filename=None):
if filename is None:
filename = self.config.base_metadata_filename
base, extension = os.path.splitext(filename)
filename = f"{base}{'_no_new_filename_specified'}{extension}"
path = os.getenv('suncet_data') + '/metadata/'
self.metadata.to_csv(path + filename, index=False)
def run(self):
if self.config.make_level0_5:
level0_5 = Level0_5(self.config)
level0_5.run()
if self.config.make_level1:
level1 = Level1(self.config)
level1.make(level0_5_to_process=os.getenv('suncet_data') + 'level0_5/')
pass
if __name__ == "__main__":
processor = Processor(config_filename=os.getcwd() + '/suncet_processing_pipeline/config_files/config_default.ini')
processor.run()