Skip to content
Snippets Groups Projects
Commit 1ae19ad0 authored by Francois Dall'Asta's avatar Francois Dall'Asta :speech_balloon:
Browse files

updated obs_data file to read 12M data

parent 2462f85f
No related branches found
No related tags found
No related merge requests found
...@@ -84,21 +84,19 @@ class ObsData: ...@@ -84,21 +84,19 @@ class ObsData:
def find_cdf_files(self, path): def find_cdf_files(self, path):
""" """
find all files with .cdf extension in path directory and find all files with .cdf extension in path directory and
returns the list of 4-month data and the 1-month data. returns the list the 12-month data.
""" """
brut_files_1M, brut_files_4M = [], [] brut_files_12M = []
for dirpath, dirnames, filenames in os.walk(path): for dirpath, dirnames, filenames in os.walk(path):
for filename in [f for f in filenames if f.endswith(".cdf")]: for filename in [f for f in filenames if f.endswith(".cdf")]:
name = os.path.join(dirpath, filename) name = os.path.join(dirpath, filename)
if '4M' in filename: if '12M' in filename:
brut_files_4M.append(name) brut_files_12M.append(name)
elif '1M' in filename:
brut_files_1M.append(name)
else: else:
print('file {} do not match requirements'.format(filename)) print('file {} do not match requirements'.format(filename))
return brut_files_1M, brut_files_4M return brut_files_12M
def loadFromDirectory(self, dataDirectory, cdf_type='4M'): def loadFromDirectory(self, dataDirectory, cdf_type='12M'):
""" """
Reads VO files into CHAMP, SWARM, GO and other satellites files in Magnetic ObservatoryGroups. Reads VO files into CHAMP, SWARM, GO and other satellites files in Magnetic ObservatoryGroups.
...@@ -110,15 +108,13 @@ class ObsData: ...@@ -110,15 +108,13 @@ class ObsData:
cdf_name_shortcuts = ['GO', 'CH', 'SW', 'OR', 'CR', 'CO'] cdf_name_shortcuts = ['GO', 'CH', 'SW', 'OR', 'CR', 'CO']
# find all cdf filenames in data directory # find all cdf filenames in data directory
cdf_files_1M, cdf_files_4M = self.find_cdf_files(dataDirectory) cdf_files_12M = self.find_cdf_files(dataDirectory)
for obsGroupName, cdf_shortcut in zip(possible_ids, cdf_name_shortcuts): for obsGroupName, cdf_shortcut in zip(possible_ids, cdf_name_shortcuts):
GO = True if obsGroupName == 'GROUND' else False GO = True if obsGroupName == 'GROUND' else False
if cdf_type == '4M': if cdf_type == '12M':
cdf_files = cdf_files_4M cdf_files = cdf_files_12M
elif cdf_type == '1M':
cdf_files = cdf_files_1M
else: else:
raise ValueError('cdf_type {} not recognized'.format(cdf_type)) raise ValueError('cdf_type {} not recognized'.format(cdf_type))
# extract file that starts with the cdf name shortcut, i.e. GO, CH, SW.... # extract file that starts with the cdf name shortcut, i.e. GO, CH, SW....
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment