<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 This is the demonstration how to use NEDO data process utility
Step1:  Load the data into a NEDOLocation object
Step2:  main_df adds the column names into the raw data and convert it to a pandas.DataFrame object
Convert the NEDO data into a more useful form
Add column names into the raw data does not make the dataframe easier to use. nedo_data_reader can "unstack" the data, i.e., making each row an entry of particular time.
Step3:  Calculate the overall insolation
Step4:  Extrat DNI
Daily METPV-11 data records the solar insolation on a horizontal plane. We can use get_DNI() to recalculate the DNI data.
Step5:  Calculate DNI on a tilted surface
Step6:  Visualize the sun irradiances in angular plot
Step7:  Analyze angle of incidence
<ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
from pypvcell.solarcell import SQCell,MJCell,TransparentCell
from pypvcell.illumination import Illumination
from pypvcell.spectrum import Spectrum
from pypvcell.metpv_reader import NEDOLocation
from pvlib.location import Location
from pvlib.tracking import SingleAxisTracker
from pvlib.irradiance import total_irrad,aoi_projection
nedo_solar_file='hm51106year.csv'
Explanation: This is the demonstration how to use NEDO data process utility
End of explanation
ngo_loc=NEDOLocation(nedo_solar_file)
df=ngo_loc.main_df
ngo_loc.main_df.head()
Explanation: Load the data into a NEDOLocation object
End of explanation
%%time
ngo_df=ngo_loc.extract_unstack_hour_data(norm=False)
ngo_df.head()
ngo_df.to_csv("ngo_df.csv")
Explanation: main_df adds the column names into the raw data and convert it to a pandas.DataFrame object
Convert the NEDO data into a more useful form
Add column names into the raw data does not make the dataframe easier to use. nedo_data_reader can "unstack" the data, i.e., making each row an entry of particular time.
End of explanation
ngo_df[['GHI','DHI','dHI']].sum()
Explanation: Calculate the overall insolation
End of explanation
ngo_dni=ngo_loc.get_DNI()
ngo_dni.head()
plt.plot(ngo_dni)
plt.ylim([0,1000])
Explanation: Extrat DNI
Daily METPV-11 data records the solar insolation on a horizontal plane. We can use get_DNI() to recalculate the DNI data.
End of explanation
ngo_tilt_irr=ngo_loc.tilt_irr(include_solar_pos=True)
ngo_tilt_irr.head()
ngo_tilt_irr.columns
plt.plot(ngo_tilt_irr['poa_direct'],alpha=0.5,label='incidence on tilt surface')
plt.plot(ngo_dni,alpha=0.5,label='DNI')
plt.ylim([0,1000])
plt.legend()
Explanation: Calculate DNI on a tilted surface
End of explanation
from matplotlib.colors import LogNorm
filtered_df=ngo_tilt_irr.loc[(ngo_tilt_irr['poa_direct']>1) & (ngo_tilt_irr['poa_direct']<500),
                             ["azimuth","zenith",'poa_direct']]
ax = plt.subplot(111, projection='polar')
ax.plot(filtered_df['azimuth'].values*np.pi/180-np.pi/2, 
        filtered_df['zenith'].values-ngo_loc.latitude,'.')
plt.show()
import matplotlib as mpl
filtered_df=ngo_tilt_irr.loc[(ngo_tilt_irr['poa_direct']>1) & (ngo_tilt_irr['poa_direct']<500),
                             ["azimuth","zenith",'poa_direct']]
ax = plt.subplot(111, projection='polar')
colormap = plt.get_cmap('hsv')
norm = mpl.colors.Normalize(1, 400)
cax=ax.scatter(filtered_df['azimuth'].values*np.pi/180-np.pi/2, filtered_df['zenith'].values-ngo_loc.latitude,
           c=filtered_df['poa_direct'].values,s=200,norm=norm,alpha=0.5)
plt.colorbar(cax)
plt.savefig("nagoya_angular.png",dpi=600)
plt.show()
Explanation: Visualize the sun irradiances in angular plot
End of explanation
ngo_tilt_irr.columns
plt.hist(ngo_tilt_irr['aoi'],weights=ngo_tilt_irr['poa_direct'],bins=100)
plt.show()
Explanation: Analyze angle of incidence
End of explanation
<END_TASK>