def test_util_mean_earth_sun_distance_no_error(self):
        try:
            util.mean_earth_sun_distance(self.aware)
        except NoTimeZoneInfoError:
            self.fail("""'NoTimeZoneInfoError' should not be raised \
as 'datetime' object is tz-aware.""")
 def test_util_mean_earth_sun_distance_raise_error(self):
     with self.assertRaises(NoTimeZoneInfoError):
         util.mean_earth_sun_distance(self.unaware)
Beispiel #3
0
            sta_df = df[t_columns + [station]].reset_index(drop=True)
            DOY = sta_df.doy[0]

            # Convert time related columns to datetimes and store them in a new dataframe
            dt_df = pd.to_datetime(
                sta_df.s.apply(str) + ' ' + sta_df.y.apply(str) + ' ' +
                sta_df.doy.apply(str) + ' ' + sta_df.hst.apply(str),
                format='%S %Y %j %H%M')
            dt_df = dt_df.dt.tz_localize('HST')  # This sets tzinfo to HST
            # dt_df = dt_df.dt.tz_convert(None) # This converts time to UTC and removes tzinfo

            az_df = pd.DataFrame()
            el_df = pd.DataFrame()
            cs_df = pd.DataFrame()
            for datetime in dt_df:
                KD = util_csm.mean_earth_sun_distance(datetime)
                DEC = util_csm.declination_degree(datetime, TY)
                altitude = solar.get_altitude(lat, lon, datetime)
                azimuth = solar.get_azimuth(lat, lon, datetime)

                if simple_csm == 'kasten':
                    ghi_csm = 910 * math.sin(math.radians(altitude))
                if simple_csm == 'haurwitz':
                    ghi_csm = 1098 * math.sin(
                        math.radians(altitude)) * math.exp(
                            -0.057 / (math.sin(math.radians(altitude))))

                cs_df = cs_df.append({'cs': ghi_csm}, ignore_index=True)
                el_df = el_df.append({'elevation': altitude},
                                     ignore_index=True)
                az_df = az_df.append({'azimuth': azimuth}, ignore_index=True)