async def plot( *, resource_url: str = Query(..., title="Resource URL", description="URL to a netcdf resource"), get: str = Query( ..., title="Query string", description= "Receive list of parameters or get the plot, specifying the variable name", regex='^(param|plot)$'), variable: str = Query(None, title="Variable name", description="String with the NetCDF Variable name")): if get == 'param': #variables, datetimeranges = get_plottable_variables(netCDF4.Dataset(str(resource_url), mode="r")) #return {"y_axis": [i[0] for i in variables]} return get_plottable_variables(resource_url) if get == 'plot': if not variable or variable not in get_plottable_variables( resource_url)["y_axis"]: raise HTTPException(status_code=404, detail="Variable not found") data = get_data(resource_url, variable, resample=None) #json_plot = create_plot(data) json_plot = create_page(data) json_data = json_item(json_plot, target='tsplot') #json_data['test'] = "<b>BOLD</b>" return json_data if get == 'data': if not variable or variable not in get_plottable_variables( resource_url)["y_axis"]: raise HTTPException(status_code=404, detail="Variable not found") data = get_data(resource_url, variable, resample=None) return data
async def plot( *, resource_url: str = Query(..., title="Resource URL", description="URL to a NetCDF resource"), get: str = Query( ..., title="Query string", description= "Receive list of parameters or get the plot, specifying the variable name", regex='^(param|plot)$'), variable: str = Query(None, title="Variable name", description="String with the NetCDF Variable name"), metadata: bool = Query( False, title="metadata", description="If true add metadata tab to the plot widget")): if get == 'param': return get_variables(resource_url) if get == 'plot': data = get_data(resource_url, variable) # json_plot = create_plot(data) json_plot = create_page(data, metadata=metadata) json_data = json_item(json_plot, target='tsplot') return json_data
async def tsplot(*, resource_url: str, get: str, variable: str = None): if get == 'param': #variables, datetimeranges = get_plottable_variables(netCDF4.Dataset(str(resource_url), mode="r")) #return {"y_axis": [i[0] for i in variables]} return get_plottable_variables(resource_url) if get == 'plot': data = get_data(resource_url, variable, resample=None) #json_plot = create_plot(data) json_plot = create_page(data) json_data = json_item(json_plot, target='tsplot') #json_data['test'] = "<b>BOLD</b>" return json_data
async def plot( *, resource_url: str = Query(..., title="Resource URL", description="URL to a NetCDF resource"), get: str = Query( ..., title="Query string", description= "Receive list of parameters or get the plot, specifying the variable name", regex='^(param|plot)$'), variable: str = Query(None, title="Variable name", description="String with the NetCDF Variable name"), axis: str = Query(None, title="axis type", description="String with the NetCDF Variable name", regex='^(x_axis|y_axis)$'), metadata: bool = Query( False, title="metadata", description="If true add metadata tab to the plot widget")): if get == 'param': try: return get_variables(resource_url) except IOError: raise HTTPException( status_code=422, detail="URL To invalid or not supported NetCDF resource") if get == 'plot': if not axis: axis = 'y_axis' data = get_data(resource_url, variable, axis) # json_plot = create_plot(data) json_plot = create_page(data, metadata=metadata) json_data = json_item(json_plot, target='tsplot') return json_data