def _process_gsm_weather(self, gsm_df):
     
     # 不要な列を削る
     drop_columns = [
         #'南北風', 
         #'積算降水量_12h',
         #'積算降水量_06h', 
         '積算降水量_03h', 
         '下層雲量', 
         '中層雲量',
         '地上気圧', 
         '上昇流',
     ]
     gsm_df = wdfproc.drop_columns(gsm_df, drop_columns)
     
     # 地表と指定気圧面の差を追加する
     #gsm_df = gsm.add_difference_surface_and_pall(gsm_df)
     
     # 時間変化量を追加する
     #gsm_df = util.add_time_variation(gsm_df)
     
     # 月平均との差分を追加する
     #gsm_df = util.add_difference_monthly_mean(gsm_df, ['気温', '高度'])
     
     # 指定した緯度,経度のデータを抽出する
     #   静岡〜いわき (35,138.8)〜(36.6,140.7)
     #gsm_df = gsm.extract_latitude_and_longitude(gsm_df, latitudes=(35,37), longitudes=(138, 141))
     
     # 指定気圧面の湿数を追加する
     gsm_df = gsm.add_moisture(gsm_df)
     
     # 指定気圧面の相当温位を追加する
     gsm_df = gsm.add_potential_temperature(gsm_df)
     
     return gsm_df
Exemple #2
0
    def _process_gsm_weather(self, gsm_df):

        # 不要な列を削る
        drop_columns = [
            '高度',
            '地上気圧',
            '全雲量',
            '下層雲量',
            '積算降水量_06h',
            '積算降水量_12h',
            #    '高度', '東西風', '南北風', '地上気圧',
            #    '下層雲量', '中層雲量', '上層雲量',
            #    '積算降水量_03h', '積算降水量_06h', '積算降水量_12h',
        ]
        gsm_df = wdfproc.drop_columns(gsm_df, drop_columns)

        # 地表と指定気圧面の差を追加する
        #gsm_df = gsm.add_difference_surface_and_pall(gsm_df)

        # 時間変化量を追加する
        #gsm_df = util.add_time_variation(gsm_df)

        # 指定した緯度,経度のデータを抽出する
        #   静岡〜いわき (35,138.8)〜(36.6,140.7)
        gsm_df = gsm.extract_latitude_and_longitude(gsm_df,
                                                    latitudes=(35, 37),
                                                    longitudes=(138, 141))

        return gsm_df
    def _preprocess_ground_weather(self, ground_df):
        
        # 9時と21時のデータを抽出する
        ground_df = util.extract_row_isin(ground_df, '時', [9, 21])
        
        # 天気記号を数値に変換する
        ground_df = wdfproc.convert_symbol_to_number(ground_df)
        
        # 地上気象データから不要データを除去する
        ground_df = wdfproc.drop_unneeded_ground(ground_df)

        # 風速・風向きを数値に変換する
        ground_df = wdfproc.convert_wind_to_vector_ground(ground_df)

        # 天気を数値に変換する
        ground_df = wdfproc.convert_weather_to_interger(ground_df)

        # 雲量を浮動小数点数に変換する
        ground_df = wdfproc.convert_cloud_volume_to_float(ground_df)

        # 天気を指定した境界値で分類する
        #  - 水戸は3分割、それ以外は○分割にする
        label_name = 'Mito_天気'
        weather_cols = [col for col in ground_df.columns if('天気' in col)]
        weather_cols.pop( weather_cols.index(label_name) )
        ground_df = wdfproc.replace_weather(
                            ground_df, columns=weather_cols, 
                             mode=wdfproc.WeatherConvertMode.Coarse)
        
        ground_df = wdfproc.replace_weather(ground_df, columns=[label_name])

        # 浮動小数点数を32ビットに変換する
        ground_df = util.type_to_float32(ground_df)

        # 不要な列を除去する
        ground_df = wdfproc.drop_columns(
            ground_df, 
            [ '現地気圧', '露点温度', '蒸気圧', '日照時間', 
              '降雪', '積雪', '視程', '全天日射' ]
            #[ '現地気圧', '海面気圧', '気温', '露点温度', '蒸気圧', '日照時間', 
            #  '降雪', '積雪', '雲量', '視程', '全天日射', '降水量', '風速' ]
            #[ '現地気圧', '海面気圧', '気温', '露点温度', '蒸気圧', '日照時間', 
            #  '降雪', '積雪', '雲量', '視程', '全天日射', '降水量' ]
            #[ '現地気圧', '海面気圧', '気温', '露点温度', '蒸気圧', '日照時間', 
            #  '降雪', '積雪', '視程', '全天日射' ]
        )
        
        print(ground_df.info())
        
        return ground_df
Exemple #4
0
    def _preprocess_highrise_weather(self, highrise_df):

        # 高層気象データから不要データを除去する
        #highrise_df = wdfproc.drop_unneeded_higirise(highrise_df)

        # 風速・風向きを数値に変換する
        highrise_df = wdfproc.convert_wind_to_vector_highrise(highrise_df)

        # 浮動小数点数を32ビットに変換する
        highrise_df = wdfproc.type_to_float32(highrise_df)

        # 不要な列を除去する
        highrise_df = wdfproc.drop_columns(
            highrise_df, ['高度', '1000', '925', '900', '800', '600', '400'])
        #highrise_df.to_csv('highrise4.csv')

        print(highrise_df.info())

        return highrise_df
    def _preprocess_ground_weather(self, ground_df):

        # 9時と21時のデータを抽出する
        ground_df = util.extract_row_isin(ground_df, '時', [9, 21])

        # 天気記号を数値に変換する
        ground_df = wdfproc.convert_symbol_to_number(ground_df)

        # 地上気象データから不要データを除去する
        ground_df = wdfproc.drop_unneeded_ground(ground_df)

        # 風速・風向きを数値に変換する
        ground_df = wdfproc.convert_wind_to_vector_ground(ground_df)

        # 天気を数値に変換する
        ground_df = wdfproc.convert_weather_to_interger(ground_df)

        # 雲量を浮動小数点数に変換する
        ground_df = wdfproc.convert_cloud_volume_to_float(ground_df)

        # 天気を晴れ,くもり,雨のいずれかに分類する
        weather_cols = [col for col in ground_df.columns if ('天気' in col)]
        ground_df = wdfproc.replace_weather(
            ground_df,
            columns=weather_cols,
            mode=wdfproc.WeatherConvertMode.Coarse)

        # 浮動小数点数を32ビットに変換する
        ground_df = util.type_to_float32(ground_df)

        # 不要な列を除去する
        ground_df = wdfproc.drop_columns(
            ground_df,
            #[ '現地気圧', '海面気圧', '降水量', '気温', '露点温度', '蒸気圧', '湿度', '風速',
            #  '日照時間', '全天日射', '降雪', '積雪', '視程', ]
            ['現地気圧', '露点温度', '蒸気圧', '日照時間', '降雪', '積雪', '視程', '全天日射'])

        print(ground_df.info())

        return ground_df
 def _load_ground_weather(self, reload):
     
     # 保存ファイルの有無を確認する
     os.makedirs(self._temp_dir, exist_ok=True)
     ground_weather_csv = os.path.join(self._temp_dir, 'ground_weather.csv')
     exist_csv = os.path.isfile(ground_weather_csv)
     
     if (reload == False) and (exist_csv == True):
         # 読み込み済み、かつ、リロード無しの場合は、
         # 保存したファイルを読み込む
         ground_df = pd.read_csv(ground_weather_csv, index_col=0, parse_dates=[1])
     else:
         ground_dir = os.path.join(self._input2_dir, 'ground_weather')
         ground_df = wfile.get_ground_weather(ground_dir)
         ground_df.to_csv(ground_weather_csv)
     
     # 3時,9時,15時,21時のデータを抽出する
     ground_df = util.extract_row_isin(ground_df, '時', [3, 9, 15, 21])
     
     # 天気記号を数値に変換する
     ground_df = wdfproc.convert_symbol_to_number(ground_df)
     
     # 地上気象データから不要データを除去する
     ground_df = wdfproc.drop_unneeded_ground(ground_df)
     
     # 風速・風向きを数値に変換する
     ground_df = wdfproc.convert_wind_to_vector_ground(ground_df)
     
     # 天気を数値に変換する
     ground_df = wdfproc.convert_weather_to_interger(ground_df)
     
     # 雲量を浮動小数点数に変換する
     ground_df = wdfproc.convert_cloud_volume_to_float(ground_df)
     
     # 天気を所定の境界値で分類する
     if self._weather_convert_mode == 'rain_or_not':
         convert_mode = WeatherConvertMode.RainOrNot
     else:
         convert_mode = WeatherConvertMode.Coarse
     
     # 天気を晴れ,くもり,雨のいずれかに分類する
     weather_cols = [col for col in ground_df.columns if('天気' in col)]
     ground_df = wdfproc.replace_weather(
                         ground_df, columns=weather_cols, 
                          mode=wdfproc.WeatherConvertMode.Coarse)
     
     # 月の平均値を追加する
     #ground_df = util.add_monthly_mean(ground_df, ['天気'])
     
     # 不要な列を除去する
     ground_df = wdfproc.drop_columns(
         ground_df, 
         #[ '現地気圧', '海面気圧', '降水量', '気温', '露点温度', '蒸気圧', '湿度', '風速', 
         #  '日照時間', '全天日射', '降雪', '積雪', '視程', ]
         [ '現地気圧', '露点温度', '蒸気圧', '日照時間', 
           '降雪', '積雪', '視程', '全天日射' ]
     )
     
     #ground_df = wdfproc.replace_weather(ground_df, columns=[self._label_name], mode=convert_mode)
     
     # 水戸の天気,海面気圧,気温,湿度を抽出する
     #extract_columns = ['日付', '時', 'Mito_海面気圧(hPa)', 'Mito_気温(℃)', 'Mito_湿度(%)', 'Mito_天気']
     #ground_df = ground_df.loc[:, extract_columns]
     
     return ground_df