Skip to content

Commit

Permalink
Switched to use geom file in local directory for ingest of source meta
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpmcmanus committed Jul 18, 2024
1 parent 9b08750 commit 919ac22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 3 additions & 5 deletions run/createIngestNewModelSourceMeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def addMeta(ingestPath, inputFilePath, inputDataSource, inputSourceName, inputSo

# Add station csv file as input and change this to read station csv file
# Create list of geom files, to be ingested by searching the input directory for geom files.

df = pd.read_csv(inputFilePath, usecols=[0], names=['station_name'])
stationNameList = [format(x, 'd') for x in list(df['station_name'].values)]
df = getStationID(stationNameList)
Expand All @@ -136,7 +137,7 @@ def addMeta(ingestPath, inputFilePath, inputDataSource, inputSourceName, inputSo
df=df.reindex(columns=newColsOrder)

# Write dataframe to csv file
outputFile = 'source_'+inputSourceName+'_stationdata_'+inputSourceArchive+'_'+inputLocationType+'_'+inputDataSource+'_meta.csv'
outputFile = 'source_'+inputSourceName+'_stationdata_'+inputSourceArchive+'_'+inputLocationType+'_'+inputDataSource+'_'+inputSourceInstance+'_meta.csv'
df.to_csv(ingestPath+outputFile, index=False, header=False)

def runIngestModelSourceData(ingestDir, inputLocationType):
Expand All @@ -156,17 +157,14 @@ def runIngestModelSourceData(ingestDir, inputLocationType):
df = getSourceModelMetaLocationType(inputLocationType)

# get geom file
inputFile = glob.glob(ingestDir+"stations/geom_*.csv")
inputFile = glob.glob("stations/geom_*.csv")

# run addmMeta for the sources from getSourceObsMetaLocationType
for index, row in df.iterrows():
# ingestPath, inputFilePath, inputDataSource, inputSourceName, inputSourceArchive, inputSourceInstance, inputForcingMetclass, inputUnits, inputLocationType
addMeta(ingestDir, inputFile[0], row['data_source'], row['source_name'], row['source_archive'], row['source_instance'], row['forcing_metclass'],
row['units'], row['location_type'])

# remove geom file
os.remove(inputFile[0])

# Create list of program commands
program_list = []
program_list.append(['python','ingestTasks.py','--ingestDir',ingestDir,'--inputTask','ingestModelSourceData'])
Expand Down
5 changes: 1 addition & 4 deletions run/createIngestNewObsSourceMeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,12 @@ def runIngestObsSourceData(ingestDir, inputLocationType):
df = getSourceObsMetaLocationType(inputLocationType)

# get geom file
inputFile = glob.glob(ingestDir+"stations/geom_*.csv")
inputFile = glob.glob("stations/geom_*.csv")

# run addmMeta for the sources from getSourceObsMetaLocationType
for index, row in df.iterrows():
addMeta(ingestDir, inputFile[0], row['data_source'], row['source_name'], row['source_archive'], row['units'], row['location_type'])

# remove geom file
os.remove(inputFile[0])

# Create list of program commands
program_list = []
program_list.append(['python','ingestTasks.py','--ingestDir',ingestDir,'--inputTask','ingestObsSourceData'])
Expand Down

0 comments on commit 919ac22

Please sign in to comment.