### Example: Generate Time Wind QCld QIce Tmp Profile Source: https://www.showdoc.com.cn/metdig/7502775702484506 Example demonstrating how to load 3D grid data for various meteorological variables and then plot a time-series profile of cloud water, ice water, wind, and temperature using draw_cross.draw_time_wind_qcld_qice_tmp. ```python from metdig.io import get_model_grid from metdig.io import get_model_3D_grid from metdig.io import get_model_3D_grids from metdig.onestep.complexgrid_var.pv_div_uv import read_pv_div_uv from metdig.onestep.complexgrid_var.div_uv import read_div_uv_4d,read_div_uv_3d from metdig.onestep.complexgrid_var.vort_uv import read_vort_uv_4d from metdig.onestep.complexgrid_var.spfh import read_spfh_4D,read_spfh_3D from metdig.onestep.complexgrid_var.theta import read_theta3d from metdig.onestep.complexgrid_var.w import read_w3d from metdig.products import diag_crossection as draw_cross import metdig.cal as mdgcal import metdig.utl as mdgstda # get data u = get_model_3D_grids(...) v = get_model_3D_grids(...) qcld = get_model_3D_grids(...) qice = get_model_3D_grids(...) psfc = get_model_3D_grids(...) tmp = get_model_3D_grids(...) _, pressure = xr.broadcast(v, v['level']) terrain = pressure - psfc.values # plot draw_cross.draw_time_wind_qcld_qice_tmp(qcld, qice, tmp, u, v, terrain, ...) ``` -------------------------------- ### Example: Download CMADASS Isobaric Surface Data Source: https://www.showdoc.com.cn/metdig/8961497724779380 Example demonstrating how to call the CMADASS isobaric surface download function with specific parameters for data name, variables, and forecast hours. ```python import datetime from metdig.io.cmadass_manual_download import cmadass_psl_download_usepool fhours = [8] cmadass_psl_download_usepoo(data_name='cma_gfs', var_names=['hgt', 'u', 'v'], fhours=fhours) ``` -------------------------------- ### Example: Generate Time Wind QCld QSN Tmp Profile Source: https://www.showdoc.com.cn/metdig/7502775702484506 Example demonstrating how to load 3D grid data for various meteorological variables and then plot a time-series profile of cloud water, snow water, wind, and temperature using draw_cross.draw_time_wind_qcld_qsn_tmp. ```python from metdig.io import get_model_grid from metdig.io import get_model_3D_grid from metdig.io import get_model_3D_grids from metdig.onestep.complexgrid_var.pv_div_uv import read_pv_div_uv from metdig.onestep.complexgrid_var.div_uv import read_div_uv_4d,read_div_uv_3d from metdig.onestep.complexgrid_var.vort_uv import read_vort_uv_4d from metdig.onestep.complexgrid_var.spfh import read_spfh_4D,read_spfh_3D from metdig.onestep.complexgrid_var.theta import read_theta3d from metdig.onestep.complexgrid_var.w import read_w3d from metdig.products import diag_crossection as draw_cross import metdig.cal as mdgcal import metdig.utl as mdgstda # get data u = get_model_3D_grids(...) v = get_model_3D_grids(...) qcld = get_model_3D_grids(...) qsn = get_model_3D_grids(...) psfc = get_model_3D_grids(...) tmp = get_model_3D_grids(...) _, pressure = xr.broadcast(v, v['level']) terrain = pressure - psfc.values # plot draw_cross.draw_time_wind_qcld_qsn_tmp(qcld, qsn, tmp, u, v, terrain, ...) ``` -------------------------------- ### Example: Download CMADASS Surface Data Source: https://www.showdoc.com.cn/metdig/8961497724779380 Example demonstrating how to call the CMADASS surface data download function with specific parameters for data name, variables, and forecast hours. ```python import datetime from metdig.io.cmadass_manual_download import cmadass_sfc_download_usepool fhours = [8] cmadass_sfc_download_usepool(data_name='cma_gfs', var_names=['u10m', 'v10m'], fhours=fhours) ``` -------------------------------- ### Get Colormap with Various Styles Source: https://www.showdoc.com.cn/metdig/6157320217461930 Demonstrates how to retrieve colormaps using different predefined styles (matplotlib, met, guide, ncl) and custom color lists. Shows usage of extend and levels for advanced mapping. ```python import metdig.graphics.cmap.cm as cm_collected #matplotlib调用方式 cmap = cm_collected.get_cmap('PuOr') #met调用方式 cmap = cm_collected.get_cmap('met/rain') #guide调用方式 cmap = cm_collected.get_cmap('guide/cs26') #ncl调用方式 cmap = cm_collected.get_cmap('ncl/3saw') #自定义颜色表方式一 cmap = cm_collected.get_cmap(['#ff0000', '#00ff00' , '#0000ff']) cmap = cm_collected.get_cmap(['red', 'green', 'blue']) # 使用extend, levels cmap,norm = cm_collected.get_cmap('PuOr', extend='both', levels=[500,600,700]) cmap,norm = cm_collected.get_cmap(['white', 'red', 'green', 'blue'], extend='both', levels=[500,600,700]) cmap,norm = cm_collected.get_cmap(['red', 'green'], extend='neither', levels=[500,600,700]) ``` -------------------------------- ### Metdig Installation and Project Overview Source: https://www.showdoc.com.cn/metdig/5110402092283484 Information regarding the installation of Metdig and a general overview of the project's structure and purpose. ```APIDOC ## Metdig Installation and Project Overview ### Description This section covers the installation instructions for Metdig and provides an overview of the project's goals and structure. ### Project Structure - INDEX_HTML - ITEM_HTML - metdig - EN - metdig installation instructions - Project Description - STDA Standard Format - Visualization Examples - Application Aggregation Examples - Update Information - Product Customization (onestep) - Product Application (hub) - Data Reading (io) - Diagnostic Calculation (cal) - Product Visualization (products) - Graphics Library (graphics) - General Utility Library (utl) ### Appendix - Units: Common basic units - STDA Attribute List - Data Source and Type List - Cassandra Data Source Attributes List - CMADaaS Data Source Attributes List - ERA5 Data Source Attributes List - THREDDS Data Source Attributes List - Plotting Area Settings - Color Table Settings ``` -------------------------------- ### Invoke Composite Reflectivity Analysis Source: https://www.showdoc.com.cn/metdig/7147732468681291 Example of importing the radar module and executing the composite reflectivity analysis function. ```python import numpy as np import metdig.onestep.observation_radar as observation_radar observation_radar.cref() ``` -------------------------------- ### Invoke Combined Radar and Sounding Analysis Source: https://www.showdoc.com.cn/metdig/7147732468681291 Example of importing the radar module and executing the combined overlay analysis function. ```python import numpy as np import metdig.onestep.observation_radar as observation_radar observation_radar.cref_sounding_hgt() ``` -------------------------------- ### Import and Call get_model_3D_grid Source: https://www.showdoc.com.cn/metdig/6046494054421120 This example demonstrates how to import the get_model_3D_grid function and use it to fetch model data for a specific time, variable, and pressure levels. It also shows how to print the retrieved data and its attributes. ```python import datetime from metdig.io.era5 import get_model_3D_grid init_time = datetime.datetime(2020, 8, 2, 8) var_name = 'hgt' levels = [500, 600] data = get_model_3D_grid(init_time=init_time, var_name=var_name, levels=levels) print(data) print(data.attrs) ``` -------------------------------- ### Full Workflow for Wind, Theta, and Relative Humidity Plotting Source: https://www.showdoc.com.cn/metdig/7502775702484506 Complete example showing imports, data processing, and plotting for wind, theta, and relative humidity cross-sections. ```python from metdig.io import get_model_grid from metdig.io import get_model_3D_grid from metdig.io import get_model_3D_grids from metdig.onestep.complexgrid_var.pv_div_uv import read_pv_div_uv from metdig.onestep.complexgrid_var.div_uv import read_div_uv_4d,read_div_uv_3d from metdig.onestep.complexgrid_var.vort_uv import read_vort_uv_4d from metdig.onestep.complexgrid_var.spfh import read_spfh_4D,read_spfh_3D from metdig.onestep.complexgrid_var.theta import read_theta3d from metdig.onestep.complexgrid_var.w import read_w3d from metdig.products import diag_crossection as draw_cross import metdig.cal as mdgcal import metdig.utl as mdgstda # get data rh = get_model_3D_grid(...) u = get_model_3D_grid(...) v = get_model_3D_grid(...) tmp = get_model_3D_grid(...) hgt = get_model_grid(...) psfc = get_model_grid(...) cross_rh = mdgcal.cross_section(rh, st_point, ed_point) cross_u = mdgcal.cross_section(u, st_point, ed_point) cross_v = mdgcal.cross_section(v, st_point, ed_point) cross_tmp = mdgcal.cross_section(tmp, st_point, ed_point) cross_psfc = mdgcal.cross_section(psfc_bdcst, st_point, ed_point) cross_td = mdgcal.dewpoint_from_relative_humidity(cross_tmp, cross_rh) pressure = mdgstda.gridstda_full_like_by_levels(cross_rh, cross_tmp['level'].values) cross_theta = mdgcal.equivalent_potential_temperature(pressure, cross_tmp, cross_td) cross_terrain = pressure - cross_psfc cross_terrain.attrs['var_units'] = '' # plot draw_cross.draw_wind_theta_rh(cross_rh, cross_theta, cross_u, cross_v, cross_terrain, hgt, ...) ``` -------------------------------- ### MetDig Weather Verification Examples Source: https://www.showdoc.com.cn/metdig/5790553284902199 Demonstrates how to call the `modelver_vs_anl` function with different `show` parameters to visualize verification results. Requires importing necessary modules and defining a custom function. ```python Copyimport numpy as np import metdig.onestep.diag_dynamic as diag_dynamic import metdig.hub.ver_vs_anl as ver_vs_anl func = diag_dynamic.hgt_uv_vvel ver_vs_anl.modelver_vs_anl(func=func, show='tab') ver_vs_anl.modelver_vs_anl(func=func, show='animation') ver_vs_anl.modelver_vs_anl(func=func, show='list') ``` -------------------------------- ### Ensemble Spaghetti Plot Implementation Source: https://www.showdoc.com.cn/metdig/8962042870855665 Example demonstrating how to import the necessary modules, retrieve model grid data, and execute the spaghetti plot function. ```python from metdig.io import get_model_grid from metdig.products.diag_ensemble import draw_hgt_spaghetti # get data hgt = get_model_grid(...) # plot draw_hgt_spaghetti(hgt, ...) ``` -------------------------------- ### STDA Grid Conversion with Specified Member Source: https://www.showdoc.com.cn/metdig/5293633181173648 This example shows how to specify a value for the 'member' dimension during the conversion. This allows you to assign a specific member name, such as 'cassandra', to the STDA output. ```python import metdig import xarray as xr xrda = xr.DataArray([[271, 272, 273], [274, 275, 276]], dims=("X", "Y"), coords={"X": [10, 20], 'Y': [80, 90, 100]}) # 可以指定缺失的stda维度 stda = metdig.utl.xrda_to_gridstda(xrda, lon_dim='X', lat_dim='Y', member=['cassandra']) print(stda) ``` -------------------------------- ### Metdig Multi-Model Comparison - Thermal Height Example Source: https://www.showdoc.com.cn/metdig/5633158370706807 Compares thermal height data (U, V, Temp) from multiple models using the 'list' display. Requires importing necessary diagnostic functions. ```python import numpy as np import metdig.onestep.diag_dynamic as diag_dynamic import metdig.onestep.diag_thermal as diag_thermal import metdig.hub.compare as compare func =diag_thermal.hgt_uv_tmp compare.models_compare(func=func, show='list') ``` -------------------------------- ### Generate Temperature, Relative Humidity, and Horizontal Wind Cross-Section Source: https://www.showdoc.com.cn/metdig/7502775702484506 This example demonstrates fetching 3D and 2D gridded data, calculating cross-sections for relative humidity, temperature, and wind components, and then plotting a combined cross-section. It includes calculations for dewpoint, pressure, specific humidity, equivalent potential temperature, and terrain height. Ensure correct imports and data fetching functions are used. ```python from metdig.io import get_model_grid from metdig.io import get_model_3D_grid from metdig.io import get_model_3D_grids from metdig.onestep.complexgrid_var.pv_div_uv import read_pv_div_uv from metdig.onestep.complexgrid_var.div_uv import read_div_uv_4d,read_div_uv_3d from metdig.onestep.complexgrid_var.vort_uv import read_vort_uv_4d from metdig.onestep.complexgrid_var.spfh import read_spfh_4D,read_spfh_3D from metdig.onestep.complexgrid_var.theta import read_theta3d from metdig.onestep.complexgrid_var.w import read_w3d from metdig.products import diag_crossection as draw_cross import metdig.cal as mdgcal import metdig.utl as mdgstda # get data rh = get_model_3D_grid(...) u = get_model_3D_grid(...) v = get_model_3D_grid(...) tmp = get_model_3D_grid(...) hgt = get_model_grid(...) psfc = get_model_grid(...) cross_rh = mdgcal.cross_section(rh, st_point, ed_point) cross_u = mdgcal.cross_section(u, st_point, ed_point) cross_v = mdgcal.cross_section(v, st_point, ed_point) cross_tmp = mdgcal.cross_section(tmp, st_point, ed_point) cross_psfc = mdgcal.cross_section(psfc_bdcst, st_point, ed_point) cross_u_t, cross_v_n = mdgcal.cross_section_components(cross_u, cross_v) _, pressure = xr.broadcast(cross_rh, cross_tmp['level']) cross_terrain = pressure - cross_psfc cross_terrain.attrs['var_units'] = '' # plot draw_cross.draw_wind_tmp_rh(cross_rh, cross_tmp, cross_u, cross_v, cross_u_t, cross_v_n, cross_terrain, hgt, ...) ``` -------------------------------- ### Metdig Multi-Model Comparison - Dynamic Height Example Source: https://www.showdoc.com.cn/metdig/5633158370706807 Compares dynamic height data (U, V, V-vel) from multiple models using the 'tab' display. Requires importing necessary diagnostic functions. ```python import numpy as np import metdig.onestep.diag_dynamic as diag_dynamic import metdig.onestep.diag_thermal as diag_thermal import metdig.hub.compare as compare func = diag_dynamic.hgt_uv_vvel compare.models_compare(func=func, show='tab') ``` -------------------------------- ### Getting Description Information Source: https://www.showdoc.com.cn/metdig/7446071926747931 Retrieves descriptive information about the STDA data, including start time, forecast time, and forecast lead time. ```python description() ``` -------------------------------- ### Getting Point Description Information Source: https://www.showdoc.com.cn/metdig/7446071926747931 Retrieves descriptive information for a specific point, including start time, forecast details, and analysis point. Can include custom descriptions. ```python description_point(describe='') ``` -------------------------------- ### Registering and Using STDA Accessors Source: https://www.showdoc.com.cn/metdig/7446071926747931 Demonstrates how to register and use grid and station STDA interfaces with .stda. syntax. Requires importing metdig and xarray. ```python import metdig data = xr.DataArray([[271, 272, 273], [274, 275, 276]], dims=("X", "Y"), coords={"X": [10, 20], 'Y': [80, 90, 100]}) data = metdig.utl.xrda_to_gridstda(xrda, lon_dim='X', lat_dim='Y', member=['cassandra'], np_input_units='K', var_name='tmp') print(data.stda.lon) print(data.stda.lat) print(data.stda.values) print(data.stda.description()) ``` -------------------------------- ### Import and Call hgt_uv_wvfl Function Source: https://www.showdoc.com.cn/metdig/5480493034611760 Demonstrates how to import the necessary module and call the hgt_uv_wvfl function for generating the composite product. ```python import numpy as np import metdig.onestep.diag_moisture as diag_moisture diag_moisture.hgt_uv_wvfl() ``` -------------------------------- ### 生成位势高度、风场、风速叠加产品 Source: https://www.showdoc.com.cn/metdig/5480847641008792 使用hgt_uv_wsp函数生成包含风速数据的叠加产品。风速绘图参数可通过wsp_pcolormesh_kwargs配置。 ```python hgt_uv_wsp(data_source='cassandra', data_name='ecmwf', init_time=None, fhour=24, hgt_lev=500, uv_lev=850, is_mask_terrain=True, area='全国', is_return_data=False, is_draw=True, **products_kwargs) ``` ```python import numpy as np import metdig.onestep.diag_synoptic as diag_synoptic diag_synoptic.hgt_uv_wsp() ``` -------------------------------- ### GET /wind_profiler/by_time Source: https://www.showdoc.com.cn/metdig/7357398366325343 Retrieves wind profiler data at a specific time. ```APIDOC ## GET /wind_profiler/by_time ### Description Retrieves wind profiler data at a specific time. ### Method GET ### Endpoint /wind_profiler/by_time ### Query Parameters - **obs_time** (datetime) - Optional - Observation time - **data_name** (str) - Optional - Observation type - **var_name** (str) - Optional - Element name - **id_selected** (int or str) - Optional - Station ID - **isnearesttime** (bool) - Optional - If obs_time is not None, whether to read the nearest real-time data. Defaults to False. ### Response #### Success Response (200) - **stda** (any) - STDA format data ### Request Example ```json { "obs_time": "2023-01-01T06:00:00", "data_name": "wind", "var_name": "direction", "id_selected": "101", "isnearesttime": true } ``` ### Response Example ```json { "stda": "[STDA formatted data]" } ``` ``` -------------------------------- ### Import and Call hgt_uv_wvfldiv Function Source: https://www.showdoc.com.cn/metdig/5480493034611760 Shows how to import the required module and execute the hgt_uv_wvfldiv function to create the composite product with flux divergence. ```python import numpy as np import metdig.onestep.diag_moisture as diag_moisture diag_moisture.hgt_uv_wvfldiv() ``` -------------------------------- ### GET utl.utl_stda_attrs.get_stda_attrs Source: https://www.showdoc.com.cn/metdig/5513057766302766 Retrieves the attributes associated with the STDA standard format. ```APIDOC ## GET utl.utl_stda_attrs.get_stda_attrs ### Description Retrieves the attributes of STDA standard format data. ### Method GET ### Endpoint utl.utl_stda_attrs.get_stda_attrs(...) ### Parameters #### Path Parameters - **...** (any) - Required - Arguments required for the specific attribute retrieval function. ``` -------------------------------- ### GET /wind_profiler/by_timerange Source: https://www.showdoc.com.cn/metdig/7357398366325343 Retrieves wind profiler data within a specified time range. ```APIDOC ## GET /wind_profiler/by_timerange ### Description Retrieves wind profiler data within a specified time range. ### Method GET ### Endpoint /wind_profiler/by_timerange ### Query Parameters - **obs_st_time** (datetime) - Optional - Observation start time - **obs_ed_time** (datetime) - Optional - Observation end time - **data_name** (str) - Optional - Observation type - **var_name** (str) - Optional - Element name - **id_selected** (int or str) - Optional - Station ID ### Response #### Success Response (200) - **stda** (any) - STDA format data ### Request Example ```json { "obs_st_time": "2023-01-01T00:00:00", "obs_ed_time": "2023-01-01T12:00:00", "data_name": "wind", "var_name": "speed", "id_selected": "101" } ``` ### Response Example ```json { "stda": "[STDA formatted data]" } ``` ``` -------------------------------- ### GET /diag_ensemble/hgt_spaghetti Source: https://www.showdoc.com.cn/metdig/8961065788155852 Generates a geopotential height spaghetti plot based on specified data source, model, and forecast parameters. ```APIDOC ## GET /diag_ensemble/hgt_spaghetti ### Description Generates a geopotential height spaghetti plot using ensemble forecast data. The function supports various data sources and allows for customization of plot parameters. ### Parameters #### Request Body - **data_source** (string) - Required - Data source (e.g., 'cassandra') - **data_name** (string) - Required - Model name (e.g., 'ecmwf_ens') - **init_time** (string) - Required - Initialization time - **fhour** (integer) - Required - Forecast hour (default: 24) - **area** (string/tuple) - Optional - Plotting area (default: '全国') or latitude/longitude bounds - **is_return_data** (boolean) - Optional - Whether to return data (default: False) - **is_draw** (boolean) - Optional - Whether to draw the plot (default: True) - **hgt_contour_kwargs** (dict) - Optional - Matplotlib contour function arguments ### Request Example ```python import metdig.onestep.diag_ensemble as diag_ensemble diag_ensemble.hgt_spaghetti(data_source='cassandra', data_name='ecmwf_ens', init_time=None, fhour=24) ``` ### Response #### Success Response (200) - **ret** (dict) - Dictionary containing image and data information ``` -------------------------------- ### Import and Call time_rh_uv_tmp_vvel Source: https://www.showdoc.com.cn/metdig/5779313228458085 This snippet demonstrates how to import the necessary module and call the time_rh_uv_tmp_vvel function. Ensure numpy and metdig.onestep.diag_crossection are installed. ```python import numpy as np import metdig.onestep.diag_crossection as diag_crossection diag_crossection.time_rh_uv_tmp_vvel() ``` -------------------------------- ### Sounding Chart Initialization Source: https://www.showdoc.com.cn/metdig/7407616276019947 Initializes the sounding chart with specified parameters and provides methods for saving the chart. ```APIDOC ## Sounding Chart Initialization ### Description Initializes the sounding chart with a title, description, output directory, and image name. Supports additional optional parameters for customization. ### Method Class Method ### Endpoint N/A (Class Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Class Definition ```python class skewt_compose(title='', description='', output_dir=None, png_name='', **kwargs) ``` ### Parameters #### Required Parameters - **title** (string) - Required - The title of the chart. - **description** (string) - Required - A description for the chart. - **output_dir** (string) - Required - The directory where the output image will be saved. - **png_name** (string) - Required - The name of the output image file. #### Optional Parameters (`**kwargs`) - **nmc_logo** (boolean) - Optional - Defaults to False. Whether to add the NMC logo. - **is_clean_plt** (boolean) - Optional - Defaults to False. Whether to clean up plt resources. - **is_return_figax** (boolean) - Optional - Defaults to False. Whether to return the figure and axes objects. - **is_return_imgbuf** (boolean) - Optional - Defaults to False. Whether to return the image buffer. - **is_return_pngname** (boolean) - Optional - Defaults to False. Whether to return the image file name. ### Return Value - **obj** (object) - A sounding chart object. `obj.fig` and `obj.ax` can be used to access the matplotlib figure and axes for further development. ### Class Methods #### save() - **Description**: Explicitly saves the image to the local file system if `output_dir` and `png_name` are provided. ### Request Example ```json { "title": "Example Sounding Chart", "description": "A sample chart for demonstration", "output_dir": "/path/to/output", "png_name": "sounding_chart.png", "nmc_logo": true, "is_return_figax": true } ``` ### Response #### Success Response (200) - **obj** (object) - The sounding chart object with figure and axes. #### Response Example ```json { "message": "Sounding chart initialized successfully.", "chart_object": "" } ``` ``` -------------------------------- ### Getting Dimension Data Source: https://www.showdoc.com.cn/metdig/7446071926747931 Retrieves dimension data. If dim_name is 'fcst_time', it returns time*dtime. For other dimensions, it returns the dimension data. ```python get_dim_value(dim_name) ``` -------------------------------- ### Import and Data Fetching for FY4A Overlay Product Source: https://www.showdoc.com.cn/metdig/7502438675528640 This snippet demonstrates the necessary imports and data fetching steps before calling the drawing function. It includes retrieving model grid data, station observations, and FY AWX data, then calculating wind components. ```python from metdig.io.cassandra import get_model_grid from metdig.io.cassandra import get_obs_stations from metdig.io.cassandra import get_fy_awx from metdig.products.observation_satelite import draw_fy4air_sounding_hgt import metdig.cal as mdgcal # get data ir = get_fy_awx(...) hgt = get_model_grid(...) sounding_wsp = get_obs_stations(...) sounding_wdir = get_obs_stations(...) # 计算uv sounding_u, sounding_v = mdgcal.wind_components(sounding_wsp, sounding_wdir) # plot draw_fy4air_sounding_hgt(ir, hgt, sounding_u, sounding_v, ...) ``` -------------------------------- ### GET get_stda_attrs Source: https://www.showdoc.com.cn/metdig/5292176928737538 Retrieves the attribute dictionary for a specified variable name using optional data source, type, and name filters. ```APIDOC ## GET get_stda_attrs ### Description Retrieves a dictionary of attributes for a given variable name, optionally filtered by data source, data type, and data name. ### Method GET ### Parameters #### Path Parameters - **var_name** (str) - Required - The name of the element/variable. #### Query Parameters - **data_source** (str) - Optional - The source of the data. - **data_type** (str) - Optional - The type of the data. - **data_name** (str) - Optional - The name of the data model. ### Request Example ```python import metdig attrs = metdig.utl.get_stda_attrs(var_name='hgt', data_source='cassandra', data_type='high', data_name='ecmwf') ``` ### Response #### Success Response (200) - **dictionary** (dict) - A dictionary containing the attribute list for the requested variable. #### Response Example { "data_source": "cassandra", "level_type": "", "var_name": "hgt", "var_cn_name": "位势高度", "var_units": "dagpm", "valid_time": 0, "data_type": "high", "data_name": "ecmwf" } ``` -------------------------------- ### Call Time-Series Divergence, Vorticity, Absolute Humidity, and Wind Source: https://www.showdoc.com.cn/metdig/5779313228458085 This is a basic example of how to call the time_div_vort_spfh_uv function. Ensure necessary libraries are imported. ```python import numpy as np import metdig.onestep.diag_crossection as diag_crossection diag_crossection.time_div_vort_spfh_uv() ``` -------------------------------- ### 读取单层多时次观测站点数据接口定义 Source: https://www.showdoc.com.cn/metdig/5252854159088274 定义了 get_obs_stations_multitime 函数的参数结构,用于获取时间序列观测数据。 ```python get_obs_stations_multitime(obs_times=None, data_name=None, var_name=None, id_selected=None, extent=None, x_percent=0, y_percent=0, is_save_other_info=False) ``` -------------------------------- ### Call Time-Series Divergence, Vorticity, Relative Humidity, and Wind Source: https://www.showdoc.com.cn/metdig/5779313228458085 This example demonstrates how to invoke the time_div_vort_rh_uv function. Make sure to import the required modules. ```python import numpy as np import metdig.onestep.diag_crossection as diag_crossection diag_crossection.time_div_vort_rh_uv() ``` -------------------------------- ### 读取单层单时次模式网格数据接口定义 Source: https://www.showdoc.com.cn/metdig/5252854159088274 定义了从Cassandra读取模式网格数据的函数签名及参数列表。 ```python get_model_grid(init_time=None, fhour=None, data_name=None, var_name=None, level=None, extent=None, x_percent=0, y_percent=0) ``` -------------------------------- ### Other Planar Graph General Methods Source: https://www.showdoc.com.cn/metdig/9074356601771430 This section details the general methods for plotting other planar graphs, including a code example and parameter descriptions for the `cross_section_hgt` function. ```APIDOC ## Other Planar Graph General Methods ### Description Provides general methods for plotting other planar graphs. ### Method N/A (This describes a function usage, not a specific HTTP method) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```python Copycross_section_hgt(ax, hgt, levels=np.arange(500, 600, 4), cmap='inferno', st_point=None, ed_point=None, lon_cross=None, lat_cross=None, map_extent=(60, 145, 15, 55), h_pos=[0.125, 0.665, 0.25, 0.2]) ``` ### Response #### Success Response (200) - **Return Value**: matplotlib中其他函数的返回值 #### Response Example ```json { "example": "Specific return value depends on the underlying matplotlib function used." } ``` **Parameter Details** | Parameter | Required | Default Value | Description | |---|---|---|---| | ax | Yes | | | | hgt | Yes | | | | levels | Yes | | | | cmap | Yes | | | | st_point | Yes | | | | ed_point | Yes | | | | lon_cross | Yes | | | | lat_cross | Yes | | | | map_extent | Yes | | | | h_pos | Yes | | | | sizes | Yes | | | ``` -------------------------------- ### 读取单层单时次观测站点数据接口定义 Source: https://www.showdoc.com.cn/metdig/5252854159088274 定义了 get_obs_stations 函数的参数结构,用于获取特定时间点的观测数据。 ```python get_obs_stations(obs_time=None, data_name=None, var_name=None, level=None, id_selected=None, extent=None, x_percent=0, y_percent=0, is_save_other_info=False) ``` -------------------------------- ### Get STDA Attributes Source: https://www.showdoc.com.cn/metdig/5292176928737538 Use this function to retrieve STDA attributes for a given variable name and optional data source parameters. Ensure the 'metdig' library is imported. ```python import metdig attrs = metdig.utl.get_stda_attrs(var_name='hgt', data_source='cassandra', data_type='high', data_name='ecmwf') print(attrs) ``` -------------------------------- ### Configure Composite Reflectivity, Geopotential Height, and Sounding Wind Overlay Source: https://www.showdoc.com.cn/metdig/7147732468681291 Defines parameters for a combined product overlaying radar reflectivity, sounding wind, and geopotential height data. ```python cref_sounding_hgt(cref_obs_time=None, sounding_obs_time=None, hgt_init_time=None, hgt_fhour=24, is_mask_terrain=True, area='全国', is_return_data=False, is_draw=True, **products_kwargs) ``` -------------------------------- ### Thermal Diagnostic Analysis: Potential Temperature Calculation Source: https://www.showdoc.com.cn/metdig/5254288716043446 Calculates potential temperature using pressure and temperature. Includes parameter descriptions, a Python code example, and sample output. ```APIDOC ## POST /api/thermal/potential_temperature ### Description Calculates potential temperature using pressure and temperature. ### Method POST ### Endpoint /api/thermal/potential_temperature ### Parameters #### Request Body - **pres** (stda) - Required - total atmospheric pressure - **tmp** (stda) - Required - air temperature ### Request Example ```json { "pres": "stda_pressure_data", "tmp": "stda_temperature_data" } ``` ### Response #### Success Response (200) - **stda** (stda) - STDA standard format potential temperature data #### Response Example ```json { "stda": "stda_potential_temperature_data" } ``` ``` -------------------------------- ### 生成位势高度、风场、涡度平流叠加图 Source: https://www.showdoc.com.cn/metdig/5479360014608043 用于生成位势高度、风场和涡度平流的叠加产品。通过hgt_uv_vortadv函数调用,支持自定义平滑步长。 ```python hgt_uv_vortadv(data_source='cassandra', data_name='ecmwf', init_time=None, fhour=24, hgt_lev=500, vort_lev=850, uv_lev=500, smth_step=1, is_mask_terrain=True, area='全国', is_return_data=False, is_draw=True, **products_kwargs) ``` ```python import numpy as np import metdig.onestep.diag_dynamic as diag_dynamic diag_dynamic.hgt_uv_vortadv() ``` -------------------------------- ### Set Locale for Linux Systems Source: https://www.showdoc.com.cn/metdig/6919985653839762 On Linux systems, if you encounter 'unsupported locale setting' errors during installation or execution, run these commands before your Python code. This sets the CTYPE locale to Chinese. ```python import locale locale.setlocale(locale.LC_CTYPE, 'Chinese') ``` -------------------------------- ### 下载接口调用示例 Source: https://www.showdoc.com.cn/metdig/6046646564691097 展示了era5_sfc_sameperiod_download_usepool函数的基本调用方式,包含参数配置。 ```python era5_sfc_sameperiod_download_usepool(years=np.arange(1980,2022).tolist(), month=7, day=10, beforeday=3, afterday=3, var_names=['u10m','u100m', 'v10m','v100m', 'psfc', 'tcwv', 'prmsl','t2m','td2m','rain01','cape','cin','k_idx'], hour=np.arange(0,24,1).tolist(), extent=[50, 160, 0, 70], download_dir=None, max_pool=2, is_overwrite=True, is_return_data=True) ``` -------------------------------- ### 生成位势高度、风场、水平散度叠加图 Source: https://www.showdoc.com.cn/metdig/5479360014608043 用于生成位势高度、风场和水平散度的叠加产品。通过hgt_uv_div函数调用,默认使用850hPa作为散度层次。 ```python hgt_uv_div(data_source='cassandra', data_name='ecmwf', init_time=None, fhour=24, hgt_lev=500, div_lev=850, is_mask_terrain=True, smth_stp=5, area='全国', is_return_data=False, is_draw=True, **products_kwargs) ``` ```python import numpy as np import metdig.onestep.diag_dynamic as diag_dynamic diag_dynamic.hgt_uv_div() ``` -------------------------------- ### Getting STDA Data by Dimension Name Source: https://www.showdoc.com.cn/metdig/7446071926747931 Retrieves STDA data based on dimension names. Grid STDA is limited to 2D data. Station STDA is a pd.DataFrame and ignores xdim/ydim. ```python get_value(ydim='lat', xdim='lon') ``` -------------------------------- ### Water Vapor Flux Divergence Calculation Source: https://www.showdoc.com.cn/metdig/6174811357512148 Calculates water vapor flux divergence using wind components and specific humidity. The function signature is provided, but a full example is not available in the source. ```python water_wapor_flux_divergence(u,v,spfh) ``` -------------------------------- ### Time-Pressure Profile Drawing Board Source: https://www.showdoc.com.cn/metdig/7407616276019947 Initializes a drawing board for time-pressure profile plots. ```APIDOC ## class cross_timepres_compose ### Description Initializes a drawing board for time-pressure profile visualization. ### Parameters - **levels** (list) - Required - Pressure levels - **times** (list) - Required - Time points - **title** (string) - Required - Graphical title - **description** (string) - Required - Description information - **output_dir** (string) - Required - Output directory - **png_name** (string) - Required - Image filename ### Response - **obj** (object) - Drawing board object containing fig and ax attributes. ``` -------------------------------- ### Wind, Temperature, Relative Humidity, and Precipitation Overlay Source: https://www.showdoc.com.cn/metdig/5486439310133952 Customizes and generates an overlay product for wind, temperature, relative humidity, and precipitation. ```APIDOC ## POST /api/diag_station/uv_tmp_rh_rain ### Description Generates an overlay product combining wind, temperature, relative humidity, and precipitation data based on the provided data source, model, initialization time, forecast hours, and station information. ### Method POST ### Endpoint /api/diag_station/uv_tmp_rh_rain ### Parameters #### Request Body - **data_source** (string) - Required - The data source (e.g., 'cassandra', 'cmadaas', 'era5', 'thredds'). - **data_name** (string) - Required - The model name (e.g., 'ecmwf'). - **init_time** (string) - Required - The initialization time (e.g., 'YYYY-MM-DD HH:MM:SS'). - **fhours** (list of int) - Required - Forecast hours (e.g., [3, 6, 9, ..., 36]). - **points** (object) - Required - Station information, including longitude, latitude, and an ID (e.g., {'lon': [110], 'lat': [20], 'id': ['任意点']}). - **is_return_data** (boolean) - Optional - Whether to return the data (default: False). - **is_draw** (boolean) - Optional - Whether to draw the plot (default: True). - **products_kwargs** (object) - Optional - Additional keyword arguments for product customization. - **pallete_kwargs** (object) - Optional - Additional keyword arguments for palette settings (see graphics layer draw_compose). ### Request Example ```json { "data_source": "cassandra", "data_name": "ecmwf", "init_time": null, "fhours": [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36], "points": { "lon": [110], "lat": [20], "id": ["任意点"] }, "is_return_data": false, "is_draw": true } ``` ### Response #### Success Response (200) - **ret** (object) - A dictionary containing the generated image and data. #### Response Example ```json { "ret": { "image": "", "data": "" } } ``` ``` -------------------------------- ### 位涡、风场、散度叠加定制 Source: https://www.showdoc.com.cn/metdig/5480847641008792 使用pv_div_uv函数生成指定区域和样式的叠加产品。通过products_kwargs可传入matplotlib绘图参数。 ```python pv_div_uv(data_source='cassandra', data_name='ecmwf', init_time=None, fhour=24, lvl_ana=200, levels=[700, 600, 500, 400, 300, 250, 200, 100], is_mask_terrain=True, area='全国', is_return_data=False, is_draw=True, **products_kwargs) ``` ```python import numpy as np import metdig.onestep.diag_synoptic as diag_synoptic diag_synoptic.pv_div_uv(add_city=False) ``` -------------------------------- ### Thermal Diagnostic Analysis: Equivalent Potential Temperature Calculation Source: https://www.showdoc.com.cn/metdig/5254288716043446 Calculates equivalent potential temperature using pressure, temperature, and dewpoint temperature. Includes parameter descriptions, a Python code example, and sample output. ```APIDOC ## POST /api/thermal/equivalent_potential_temperature ### Description Calculates equivalent potential temperature using pressure, temperature, and dewpoint temperature. ### Method POST ### Endpoint /api/thermal/equivalent_potential_temperature ### Parameters #### Request Body - **pres** (stda) - Required - total atmospheric pressure - **tmp** (stda) - Required - temperature of parcel - **td** (stda) - Required - dewpoint of parcel ### Request Example ```json { "pres": "stda_pressure_data", "tmp": "stda_temperature_data", "td": "stda_dewpoint_data" } ``` ### Response #### Success Response (200) - **stda** (stda) - STDA standard format equivalent potential temperature data #### Response Example ```json { "stda": "stda_equivalent_potential_temperature_data" } ``` ``` -------------------------------- ### Download Surface Data (Cassandra) Source: https://www.showdoc.com.cn/metdig/8961485542907476 Use this function to batch download hourly surface data. Specify init_time, data_name, var_names, fhours, extent, and max_pool for customization. ```python cassandra_sfc_download_usepool( init_time,data_name='cma_gfs', var_names=['u10m','u100m', 'v10m','v100m', 'psfc', 'tcwv', 'prmsl','t2m','td2m','rain01','cape','cin','k_idx'], fhours=np.arange(0,24,1).tolist(), extent=[50, 160, 0, 70], max_pool=2) ``` ```python import datetime from metdig.io.cassandra_manual_download import cassandra_sfc_download_usepool init_time = datetime.datetime(2020, 7, 25, 8) # 北京时 fhours = [0] cassandra_sfc_download_usepool(init_time, data_name='ecmwf', var_names=['u10m', 'v10m'], fhours=fhours) ``` -------------------------------- ### Basic xarray to STDA Grid Conversion Source: https://www.showdoc.com.cn/metdig/5293633181173648 This example demonstrates a basic conversion by specifying the xarray dimension names for longitude and latitude. The output STDA format will have default dimensions for member, level, time, and dtime. ```python import metdig import xarray as xr xrda = xr.DataArray([[271, 272, 273], [274, 275, 276]], dims=("X", "Y"), coords={"X": [10, 20], 'Y': [80, 90, 100]}) # 指定xrda中各个维度对应的stda的维度名称 stda = metdig.utl.xrda_to_gridstda(xrda, lon_dim='X', lat_dim='Y') print(stda) ```