Skip to content

Commit

Permalink
Tutorial 2 and load.py
Browse files Browse the repository at this point in the history
updated tutorial 2 to match the changes in analysis1axis and performance.calculateResults. Updated load.read1Result to detect if the file read already contains an index. If so, it applies that index to the dataframe. This prevents the appearance of columns like "Unnamed: 0" from showing up in your result dataframe.
  • Loading branch information
mcbrown042 committed Jul 28, 2022
1 parent 5bacb47 commit f4df75d
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 118 deletions.
21 changes: 14 additions & 7 deletions bifacial_radiance/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def read1Result(selectfile):

#resultsDict = pd.read_csv(os.path.join('results',selectfile))
resultsDF = pd.read_csv(selectfile)

if 'Unnamed: 0' in resultsDF.columns:
resultsDF.index = resultsDF['Unnamed: 0'].values
resultsDF.drop(columns='Unnamed: 0', inplace=True)

#return(np.array(temp['Wm2Front']), np.array(temp['Wm2Back']))
return resultsDF
Expand Down Expand Up @@ -207,13 +211,16 @@ def cleanResult(resultsDF, matchers=None):

if matchers is None:
matchers = ['sky','pole','tube','bar','ground', '3267', '1540']
NaNindex = [i for i,s in enumerate(resultsDF['mattype']) if any(xs in s for xs in matchers)]
NaNindex2 = [i for i,s in enumerate(resultsDF['rearMat']) if any(xs in s for xs in matchers)]
#NaNindex += [i for i,s in enumerate(frontDict['mattype']) if any(xs in s for xs in matchers)]
for i in NaNindex:
resultsDF.loc[i,'Wm2Front'] = np.NAN
for i in NaNindex2:
resultsDF.loc[i,'Wm2Back'] = np.NAN
# NaNindex = [i for i,s in enumerate(resultsDF['mattype']) if any(xs in s for xs in matchers)]
# NaNindex2 = [i for i,s in enumerate(resultsDF['rearMat']) if any(xs in s for xs in matchers)]
# #NaNindex += [i for i,s in enumerate(frontDict['mattype']) if any(xs in s for xs in matchers)]
# for i in NaNindex:
# resultsDF.loc[i,'Wm2Front'] = np.NAN
# for i in NaNindex2:
# resultsDF.loc[i,'Wm2Back'] = np.NAN

resultsDF.loc[resultsDF.mattype.str.contains('|'.join(matchers)),'Wm2Front'] = np.NAN
resultsDF.loc[resultsDF.rearMat.str.contains('|'.join(matchers)),'Wm2Back'] = np.NAN

return resultsDF

Expand Down

0 comments on commit f4df75d

Please sign in to comment.