def test_get_ensemble_forecast_using_known_service_and_db_content(self):
         utc = Calendar() # always use Calendar() stuff
         met_stations=[ # this is the list of MetStations, the gis_id tells the position, the remaining tells us what properties we observe/forecast/calculate at the metstation (smg-ts)
             MetStationConfig(gis_id=598,temperature=u'/LTM5-Nea...........-T0017A3P_EC00_ENS',precipitation=u'/LTM5-Nea...........-T0000A5P_EC00_ENS')
         ]
         
         #note: the MetStationConfig can be constructed from yaml-config
         gis_location_repository=GisLocationService() # this provides the gis locations for my stations
         smg_ts_repository = SmGTsRepository(PROD,FC_PROD) # this provide the read function for my time-series
         n_ensembles=51
         ens_station_list=[
             EnsembleStation(598,n_ensembles,
                 temperature_ens=lambda i:u'/LTM5-Nea...........-T0017A3P_EC00_E{0:02}'.format(i),
                 precipitation_ens=lambda i:u'/LTM5-Nea...........-T0000A5P_EC00_E{0:02}'.format(i),
                 wind_speed_ens=None,
                 radiation_ens=None,
                 relative_humidity_ens=None
             ),
             EnsembleStation(574,n_ensembles,
                 temperature_ens=lambda i:u'/LTM5-Tya...........-T0017A3P_EC00_E{0:02}'.format(i),
                 precipitation_ens=lambda i:u'/LTM5-Tya...........-T0000A5P_EC00_E{0:02}'.format(i),
                 wind_speed_ens=None,
                 radiation_ens=None,
                 relative_humidity_ens=None
             )
         ]
         ens_config=EnsembleConfig(n_ensembles,ens_station_list)
         geo_ts_repository = GeoTsRepository(
             epsg_id=32633,
             geo_location_repository=gis_location_repository,
             ts_repository=smg_ts_repository,
             met_station_list=met_stations,
             ens_config=ens_config) #pass service info and met_stations
 
         self.assertIsNotNone(geo_ts_repository)
         utc_period = UtcPeriod(utc.time(YMDhms(2015, 10, 1, 0, 0, 0)),utc.time(YMDhms(2015, 10, 10, 0, 0, 0)))
         ts_types= ['temperature','precipitation']
         ens_geo_ts_dict = geo_ts_repository.get_forecast_ensemble(ts_types,utc_period=utc_period,t_c=None,geo_location_criteria=None)
         self.assertIsNotNone(ens_geo_ts_dict)
         self.assertEqual(ens_config.n_ensembles,len(ens_geo_ts_dict))
         for i in range(ens_config.n_ensembles):
             for ts_type in ts_types:
                 self.assertTrue(ts_type in ens_geo_ts_dict[i].keys(),"we ecpect to find an entry for each requested type (it could be empty list though")
                 self.assertTrue(len(ens_geo_ts_dict[i][ts_type])>0,"we expect to find the series that we pass in, given they have not changed the name in SmG PROD")
     def test_get_ensemble_forecast_using_known_service_and_db_content(self):
         utc = Calendar()
         met_stations = [MetStationConfig(gis_id=402, temperature=u'/LTM5-Nea...........-T0017A3P_EC00_ENS', precipitation=u'/LTM5-Nea...........-T0000A5P_EC00_ENS')]
         gis_location_repository = GisLocationService()
         smg_ts_repository = SmGTsRepository(PREPROD, FC_PREPROD)
         n_ensembles = 51
         ens_station_list = [
             EnsembleStation(402, n_ensembles,
                 temperature_ens = lambda i:u'/LTM5-Nea...........-T0017A3P_EC00_E{0:02}'.format(i),
                 precipitation_ens = lambda i:u'/LTM5-Nea...........-T0000A5P_EC00_E{0:02}'.format(i),
                 wind_speed_ens = None,
                 radiation_ens = None,
                 relative_humidity_ens = None
             ),
             EnsembleStation(460, n_ensembles,
                 temperature_ens = lambda i:u'/LTM5-Tya...........-T0017A3P_EC00_E{0:02}'.format(i),
                 precipitation_ens = lambda i:u'/LTM5-Tya...........-T0000A5P_EC00_E{0:02}'.format(i),
                 wind_speed_ens = None,
                 radiation_ens = None,
                 relative_humidity_ens = None
             )
         ]
         ens_config = EnsembleConfig(n_ensembles, ens_station_list)
         geo_ts_repository = GeoTsRepository(
             epsg_id = 32633,
             geo_location_repository = gis_location_repository,
             ts_repository = smg_ts_repository,
             met_station_list = met_stations,
             ens_config = ens_config)
 
         self.assertIsNotNone(geo_ts_repository)
         utc_period = UtcPeriod(utc.time(YMDhms(2015, 10, 1, 0, 0, 0)),utc.time(YMDhms(2015, 10, 10, 0, 0, 0)))
         ts_types= ['temperature', 'precipitation']
         ens_geo_ts_dict = geo_ts_repository.get_forecast_ensemble(ts_types, utc_period=utc_period, t_c=None, geo_location_criteria=None)
         self.assertIsNotNone(ens_geo_ts_dict)
         self.assertEqual(ens_config.n_ensembles, len(ens_geo_ts_dict))
         for i in range(ens_config.n_ensembles):
             for ts_type in ts_types:
                 self.assertTrue(ts_type in ens_geo_ts_dict[i].keys(), "we expect to find an entry for each requested type (it could be empty list though)")
                 self.assertTrue(len(ens_geo_ts_dict[i][ts_type])>0, "we expect to find the series that we pass in by name in SmG PREPROD")
     def test_get_ensemble_forecast_using_known_service_and_db_content(self):
         utc = Calendar()
         met_stations = [MetStationConfig(gis_id=598, temperature=u'/LTM5-Nea...........-T0017A3P_EC00_ENS', precipitation=u'/LTM5-Nea...........-T0000A5P_EC00_ENS')]
         gis_location_repository = GisLocationService()
         smg_ts_repository = SmGTsRepository(PREPROD, FC_PREPROD)
         n_ensembles = 51
         ens_station_list = [
             EnsembleStation(598, n_ensembles,
                 temperature_ens = lambda i:u'/LTM5-Nea...........-T0017A3P_EC00_E{0:02}'.format(i),
                 precipitation_ens = lambda i:u'/LTM5-Nea...........-T0000A5P_EC00_E{0:02}'.format(i),
                 wind_speed_ens = None,
                 radiation_ens = None,
                 relative_humidity_ens = None
             ),
             EnsembleStation(574, n_ensembles,
                 temperature_ens = lambda i:u'/LTM5-Tya...........-T0017A3P_EC00_E{0:02}'.format(i),
                 precipitation_ens = lambda i:u'/LTM5-Tya...........-T0000A5P_EC00_E{0:02}'.format(i),
                 wind_speed_ens = None,
                 radiation_ens = None,
                 relative_humidity_ens = None
             )
         ]
         ens_config = EnsembleConfig(n_ensembles, ens_station_list)
         geo_ts_repository = GeoTsRepository(
             epsg_id = 32633,
             geo_location_repository = gis_location_repository,
             ts_repository = smg_ts_repository,
             met_station_list = met_stations,
             ens_config = ens_config)
 
         self.assertIsNotNone(geo_ts_repository)
         utc_period = UtcPeriod(utc.time(YMDhms(2015, 10, 1, 0, 0, 0)),utc.time(YMDhms(2015, 10, 10, 0, 0, 0)))
         ts_types= ['temperature', 'precipitation']
         ens_geo_ts_dict = geo_ts_repository.get_forecast_ensemble(ts_types, utc_period=utc_period, t_c=None, geo_location_criteria=None)
         self.assertIsNotNone(ens_geo_ts_dict)
         self.assertEqual(ens_config.n_ensembles, len(ens_geo_ts_dict))
         for i in range(ens_config.n_ensembles):
             for ts_type in ts_types:
                 self.assertTrue(ts_type in ens_geo_ts_dict[i].keys(), "we expect to find an entry for each requested type (it could be empty list though)")
                 self.assertTrue(len(ens_geo_ts_dict[i][ts_type])>0, "we expect to find the series that we pass in by name in SmG PREPROD")
        def test_get_ensemble_forecast_using_known_service_and_db_content(
                self):
            utc = Calendar()  # always use Calendar() stuff
            met_stations = [  # this is the list of MetStations, the gis_id tells the position, the remaining tells us what properties we observe/forecast/calculate at the metstation (smg-ts)
                MetStationConfig(
                    gis_id=598,
                    temperature=u'/LTM5-Nea...........-T0017A3P_EC00_ENS',
                    precipitation=u'/LTM5-Nea...........-T0000A5P_EC00_ENS')
            ]

            #note: the MetStationConfig can be constructed from yaml-config
            gis_location_repository = GisLocationService(
            )  # this provides the gis locations for my stations
            smg_ts_repository = SmGTsRepository(
                PROD,
                FC_PROD)  # this provide the read function for my time-series
            n_ensembles = 51
            ens_station_list = [
                EnsembleStation(
                    598,
                    n_ensembles,
                    temperature_ens=lambda i:
                    u'/LTM5-Nea...........-T0017A3P_EC00_E{0:02}'.format(i),
                    precipitation_ens=lambda i:
                    u'/LTM5-Nea...........-T0000A5P_EC00_E{0:02}'.format(i),
                    wind_speed_ens=None,
                    radiation_ens=None,
                    relative_humidity_ens=None),
                EnsembleStation(
                    574,
                    n_ensembles,
                    temperature_ens=lambda i:
                    u'/LTM5-Tya...........-T0017A3P_EC00_E{0:02}'.format(i),
                    precipitation_ens=lambda i:
                    u'/LTM5-Tya...........-T0000A5P_EC00_E{0:02}'.format(i),
                    wind_speed_ens=None,
                    radiation_ens=None,
                    relative_humidity_ens=None)
            ]
            ens_config = EnsembleConfig(n_ensembles, ens_station_list)
            geo_ts_repository = GeoTsRepository(
                epsg_id=32633,
                geo_location_repository=gis_location_repository,
                ts_repository=smg_ts_repository,
                met_station_list=met_stations,
                ens_config=ens_config)  #pass service info and met_stations

            self.assertIsNotNone(geo_ts_repository)
            utc_period = UtcPeriod(utc.time(YMDhms(2015, 10, 1, 0, 0, 0)),
                                   utc.time(YMDhms(2015, 10, 10, 0, 0, 0)))
            ts_types = ['temperature', 'precipitation']
            ens_geo_ts_dict = geo_ts_repository.get_forecast_ensemble(
                ts_types,
                utc_period=utc_period,
                t_c=None,
                geo_location_criteria=None)
            self.assertIsNotNone(ens_geo_ts_dict)
            self.assertEqual(ens_config.n_ensembles, len(ens_geo_ts_dict))
            for i in range(ens_config.n_ensembles):
                for ts_type in ts_types:
                    self.assertTrue(
                        ts_type in ens_geo_ts_dict[i].keys(),
                        "we ecpect to find an entry for each requested type (it could be empty list though"
                    )
                    self.assertTrue(
                        len(ens_geo_ts_dict[i][ts_type]) > 0,
                        "we expect to find the series that we pass in, given they have not changed the name in SmG PROD"
                    )