def handle(self, *args, **options): ps = SourceType.objects.get(code='ioc') for s in ps.station_set.filter(status='active'): apiclient = IocAPI() df = apiclient.get_df(s.code) if df is not None: serie = get_serie(s, 'SLEV') load_serie(df['SLEV'].copy(), serie.id)
def handle(self, *args, **options): ps = SourceType.objects.get(code='arso') for s in ps.station_set.filter(status='active'): apiclient = ArsoAPI() df = apiclient.get_df(s.code) if df is None: continue for k, v in ARSO_PARAMS.items(): if v in df.columns: serie = get_serie(s, v) load_serie(df[v].copy(), serie.id)
def handle(self, *args, **options): ps = SourceType.objects.get(code='davis') for s in ps.station_set.filter(status='active'): self.stdout.write("Loading station {} ... ".format(s), ending='') davisapi = DavisAPI() df = davisapi.get_df(s.code, 5) for k, v in PARAMETER_MAP.items(): if k in df.columns: serie = get_serie(s, v) load_serie(df[k].copy(), serie.id) self.stdout.write("[OK]")
def handle(self, *args, **options): ps = SourceType.objects.get(code='cnr') for s in ps.station_set.filter(status='active'): apiclient = GetitAPI() df = apiclient.get_df(s.code, 24) if df is None: continue for k, v in SOS_PARAMS.items(): print(df.head()) if v in df.columns: serie = get_serie(s, v) print(df[v]) load_serie(df[v].copy(), serie.id)
def handle(self, *args, **options): ps = SourceType.objects.get(code='mtt') for s in ps.station_set.filter(status='active'): self.stdout.write("Loading station {} ... ".format(s), ending='') apiclient = MttAPI() df = apiclient.get_df(s.code) if df is not None and df.shape[0] > 0: for k, v in PARAMETER_MAP.items(): if k in df.columns: serie = get_serie(s, v) load_serie(df[k].copy(), serie.id) self.stdout.write("[OK]") else: self.stdout.write("[FAILED]")
def handle(self, *args, **options): hours = options['hours'] ps = SourceType.objects.get(code='pessl') for s in ps.station_set.filter(status='active'): self.stdout.write("Loading station {} ... ".format(s), ending='') keys = SOURCE_AUTH['pessl'][s.network.code] pesslapi = PesslAPI(keys['public_key'], keys['private_key']) df = pesslapi.get_df(s.code, hours) if df is not None and df.shape[0] > 0: for k, v in PARAMETER_MAP.items(): if k in df.columns: serie = get_serie(s, v) load_serie(df[k].copy(), serie.id) self.stdout.write("[OK]") else: self.stdout.write("[FAILED]")
def handle(self, *args, **options): days = options['days'] daysgap = options['daysgap'] ps = SourceType.objects.get(code='cmems_wms') for station in ps.station_set.filter(status='active'): self.stdout.write( "Loading DataSource/Station {} ... ".format(station)) apiclient = CMEMSWmsDataSource(station.uri) self.stdout.write("\tLooking for registered layers/parameters ...") for pm in station.parametermapping_set.all(): parameter = pm.parameter source_uom = pm.source_parameter_uom uom = parameter.uom print(source_uom, uom, parameter) layer = pm.source_parameter_label self.stdout.write("\tLooking for registered series ...") for series in station.serie_set.filter( parameter=parameter).all(): location = series.location # print(series) self.stdout.write( "\tLoading series {}. Layer {}. Location {} ... ". format(series.id, layer, location), ending='') point = [location.geo.x, location.geo.y] df = apiclient.get_df(layer, point, timedelta=days, timegap=daysgap) # convert uom if needed if uom is not None and source_uom is not None and uom != source_uom: df['value'] = Q_(df.value.array, source_uom).to(uom).magnitude if df.shape[0] > 0: load_serie(df['value'].copy(), series.id) self.stdout.write("nrecords {}".format(df.shape[0]), ending='') self.stdout.write("[OK]") else: self.stdout.write("[FAILED]")
def handle(self, *args, **options): hours = options['hours'] ps = SourceType.objects.get(code='elmed') for s in ps.station_set.filter(status='active'): self.stdout.write("Loading station {} ... ".format(s), ending='') keys = SOURCE_AUTH['elmed'][s.network.code] elmedapi = ElmedAPI(None, keys['private_key']) df = elmedapi.get_df(s.code, hours) if df is not None and df.shape[0] > 0: for k, _v in PARAMETER_MAP.items(): if not isinstance(_v, str): v, height = _v else: v = _v height = None if k in df.columns: serie = get_serie(s, v, height=height) load_serie(df[k].copy(), serie.id) self.stdout.write("[OK]") else: self.stdout.write("[FAILED]")