Skip to content

Commit

Permalink
indexing changes to populate with external lab data and water tempera…
Browse files Browse the repository at this point in the history
…ture data
  • Loading branch information
rodrmd99 committed Jul 3, 2020
1 parent 734ff0e commit f0cad7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 55 deletions.
3 changes: 3 additions & 0 deletions SDG_FORLOOP_WITHTRYCATCH_TEMPLATE.PY
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from testing import outputDF, externalLabData

for x in range(len(outputDF['waterSampleID'])):
# print(x)
# FOR DEMO
Expand Down Expand Up @@ -29,3 +31,4 @@ for x in range(len(outputDF['waterSampleID'])):

except Exception:
pass

82 changes: 27 additions & 55 deletions format_sdg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,6 @@ def def_format_sdg(data_dir = os.getcwd() + '/NEON_dissolved-gases-surfacewater.
print("Found: " + outputDF.columns[k])

outputDF.iloc[:,k] = fieldDataProc.loc[:,fieldDataProc.columns == outputDF.columns[k]]
# outputDF.values[k, :] = 0
#fieldDataProc.values[fieldDataProc.columns == outputDF.columns[k]]
#outputDF.columns[k] = fieldDataProc[fieldDataProc.columns == outputDF.columns[k]]
#print(outputDF.columns[k])
# shared_columns_fdp = fieldDataProc.columns[k]
# values_fdp = fieldDataProc.values
# print(shared_columns_fdp)
# print(values_fdp)

#shared_columns_odf = outputDF.columns[k]
#values_odf = outputDF.values

#outputDF.values[k] = fieldDataProc.values[fieldDataProc.columns[k] == outputDF.columns[k]]
# print(fieldDataProc.columns)
# print(fieldDataProc.values[k])
# print(len(outputDF))
#print(fieldDataProc.columns[k])
#print(fieldDataProc.values[k])


#fieldDataProc.loc[outputDF.columns[k]]
#print(fieldDataProc.values[fieldDataProc.columns == outputDF.columns[k]])
#outputDF[k] = fieldDataProc[fieldDataProc.columns == outputDF.columns[k]]




outputDF['headspaceTemp'] = fieldDataProc['storageWaterTemp']
outputDF['barometricPressure'] = fieldDataProc['ptBarometricPressure']
Expand All @@ -129,39 +103,37 @@ def def_format_sdg(data_dir = os.getcwd() + '/NEON_dissolved-gases-surfacewater.
#externalLabData = np.array(outputDF)

#Populate the output file with external lab data
for x in range(len(outputDF['waterSampleID'])):
for l in range(len(outputDF['waterSampleID'])):
try:
outputDF.loc[outputDF.index[[l]], 'concentrationCO2Air'] = externalLabData.loc[externalLabData.loc[:, 'sampleID'] == outputDF.loc[outputDF.index[[l]], 'referenceAirSampleID'].item(), 'concentrationCO2'].item()
outputDF.loc[outputDF.index[[l]], 'concentrationCO2Gas'] = externalLabData.loc[externalLabData.loc[:, 'sampleID'] == outputDF.loc[outputDF.index[[l]], 'equilibratedAirSampleID'].item(), 'concentrationCO2'].item()

except Exception:
pass
try:
outputDF.loc[outputDF.index[[l]], 'concentrationCH4Air'] = externalLabData.loc[externalLabData.loc[:, 'sampleID'] == outputDF.loc[outputDF.index[[l]], 'referenceAirSampleID'].item(), 'concentrationCH4'].item()
outputDF.loc[outputDF.index[[x]], 'concentrationCH4Gas'] = externalLabData.loc[ externalLabData.loc[:, 'sampleID'] == outputDF.loc[outputDF.index[[l]], 'equilibratedAirSampleID'].item(), 'concentrationCH4'].item()

except Exception:
pass

try:
# working code
#outputDF.loc[outputDF.index[[x]], 'concentrationCO2Air'] = externalLabData.loc[:, 'concentrationCO2']
#fieldDataProc.loc[:, fieldDataProc.columns == outputDF.columns[k]]
outputDF.loc[outputDF.index[[x]], 'concentrationCO2Air'] = externalLabData.loc[[externalLabData['sampleID'] == outputDF.loc[outputDF.index[[x]], 'referenceAirSampleID']], 'concentrationCO2']
#outputDF['concentrationCO2Gas'].loc[:,(x)] = 0
#outputDF['concentrationCO2Air'][x] = externalLabData[:, 'concentrationCO2'][externalLabData['sampleID'] == outputDF['referenceAirSampleID'][x]]
#outputDF['concentrationCO2Gas'][x] = externalLabData[:, 'concentrationCO2'][externalLabData['sampleID'] == outputDF['equilibratedAirSampleID'][x]]
except NameError:
outputDF.loc[outputDF.index[[l]], 'concentrationN2OAir'] = externalLabData.loc[externalLabData.loc[:, 'sampleID'] == outputDF.loc[outputDF.index[[l]], 'referenceAirSampleID'].item(), 'concentrationN2O'].item()
outputDF.loc[outputDF.index[[l]], 'concentrationN2OGas'] = externalLabData.loc[externalLabData.loc[:, 'sampleID'] == outputDF.loc[outputDF.index[[l]], 'equilibratedAirSampleID'].item(), 'concentrationN2O'].item()
except Exception:
pass
# try:
# outputDF['concentrationCH4Air'][x] = externalLabData['concentrationCH4'][externalLabData['sampleID'] == outputDF['referenceAirSampleID'][x]]
# outputDF['concentrationCH4Gas'][x] = externalLabData['concentrationCH4'][externalLabData['sampleID'] == outputDF['equilibratedAirSampleID'][x]]
# except NameError:
# pass

# try:
# outputDF['concentrationN2OAir'][x] = externalLabData['concentrationN2O'][externalLabData['sampleID'] == outputDF['referenceAirSampleID'][x]]
# outputDF['concentrationN2OGas'][x] = externalLabData['concentrationN2O'][externalLabData['sampleID'] == outputDF['equilibratedAirSampleID'][x]]
# except NameError:
# pass

#Populate the output file with water temperature data for streams
#for m in range(len(outputDF['waterSampleID'])):
# try:
# outputDF['waterTemp'][m] = fieldSuperParent['waterTemp'][fieldSuperParent['parentSampleID'] == outputDF['waterSampleID'][m]]
# except NameError:
# if outputDF['headspaceTemp'][m].isna() is True:
# try:
# outputDF['headspaceTemp'][m] = fieldSuperParent['waterTemp'][fieldSuperParent['parentSampleID'] == outputDF['waterSampleID'][m]]
# except NameError:
# pass
for m in range(len(outputDF['waterSampleID'])):
try:
outputDF.loc[outputDF.index[[m]], 'waterTemp'] = fieldSuperParent.loc[fieldSuperParent.loc[:, 'parentSampleID'] == outputDF.loc[outputDF.index[[m]], 'waterSampleID'].item(), 'waterTemp'].item()
except Exception:
pass
if pd.isna(outputDF['headspaceTemp'][m]) is True:
try:
outputDF.loc[outputDF.index[[m]], 'headspaceTemp'] = fieldSuperParent.loc[fieldSuperParent.loc[:, 'parentSampleID'] == outputDF.loc[outputDF.index[[m]], 'waterSampleID'].item(), 'waterTemp'].item()
except Exception:
pass

#Flag values below detection (TBD)
print("**********************************************************************")
Expand Down

0 comments on commit f0cad7c

Please sign in to comment.