@@ -34,6 +34,9 @@ def read_maccrad_metadata(file_csv, name='maccrad'):
3434 ## if file is on local drive
3535 f = open (file_csv )
3636 for line in f :
37+ if "Title" in line :
38+ title = line .split (':' )[1 ].split ('(' )[0 ].strip ()
39+ name = title
3740 if "Latitude" in line :
3841 # print (line)
3942 # if line.startswith( "# Latitude"):
@@ -66,20 +69,26 @@ def read_maccrad_metadata(file_csv, name='maccrad'):
6669 tz = tz_loc )
6770
6871 return tz_raw , location
69-
72+
73+
7074def maccrad_df_to_pvlib (df_raw , tz_raw , loc , localise = True ):
7175 """Change some properties of the dataframe to be more compliant with pvlib
7276
7377 * localisation
7478 * column renaming
79+ * setting dataframe name description according to datasource
7580
7681 """
7782
7883 if localise :
7984 # timezone localisations
80- df_pvlib = localise_df (df_raw , tz_source_str = tz_raw , loc .tz )
85+ df_pvlib = localise_df (df_raw , tz_source_str = tz_raw ,
86+ tz_target_str = loc .tz )
8187 # column renaming
8288 df_pvlib .index .name = 'datetime'
89+
90+ # name the dataframe according to data source
91+ df_pvlib .df_name = loc .name
8392
8493 return df_pvlib
8594
@@ -118,13 +127,15 @@ def read_maccrad(file_csv, loc_name=None, skiprows=40, output='all'):
118127#TODO: add loc_name
119128#TODO: add reformat needs loc!
120129#TODO: add simplify output options raw or all
130+ print (output )
121131 if output == 'df_raw' :
122132 res = df_raw
123- if output == 'test' :
124- res = df_pvlib
125- else :
133+ if output == 'all' :
126134 tz_raw , loc = read_maccrad_metadata (file_csv )
135+ loc .name = (loc .name + ' @ ' + 'lat (deg. N), lon (deg. E): ' +
136+ str (loc .latitude ) + ', ' + str (loc .longitude ))
127137 df_pvlib = maccrad_df_to_pvlib (df_raw , tz_raw , loc , localise = True )
138+ # res = df_pvlib
128139 res = (df_raw , df_pvlib , loc )
129140# if output == 'loc':
130141#
0 commit comments