<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def CreateWeightTableECMWF(in_ecmwf_nc, in_catchment_shapefile, river_id, in_connectivity_file, out_weight_table, area_id=None, file_geodatabase=None):
 """ Create Weight Table for ECMWF Grids .. note:: The grids are in the RAPIDpy package under the gis/lsm_grids folder. Parameters in_ecmwf_nc: str Path to the ECMWF NetCDF grid. in_catchment_shapefile: str Path to the Catchment shapefile. river_id: str The name of the field with the river ID (Ex. 'DrainLnID' or 'LINKNO'). in_connectivity_file: str The path to the RAPID connectivity file. out_weight_table: str The path to the output weight table file. area_id: str, optional The name of the field with the area of each catchment stored in meters squared. Default is it calculate the area. file_geodatabase: str, optional Path to the file geodatabase. If you use this option, in_drainage_line is the name of the stream network feature class. (WARNING: Not always stable with GDAL.) Example: .. code:: python from RAPIDpy.gis.weight import CreateWeightTableECMWF CreateWeightTableECMWF( in_ecmwf_nc='/path/to/runoff_ecmwf_grid.nc' in_catchment_shapefile='/path/to/catchment.shp', river_id='LINKNO', in_connectivity_file='/path/to/rapid_connect.csv', out_weight_table='/path/to/ecmwf_weight.csv', ) """

    # extract ECMWF GRID
    data_ecmwf_nc = Dataset(in_ecmwf_nc)
    variables_list = data_ecmwf_nc.variables.keys()
    in_ecmwf_lat_var = 'lat'
    if 'latitude' in variables_list:
        in_ecmwf_lat_var = 'latitude'
    in_ecmwf_lon_var = 'lon'
    if 'longitude' in variables_list:
        in_ecmwf_lon_var = 'longitude'

    # convert [0, 360] to [-180, 180]
    ecmwf_lon = \
        (data_ecmwf_nc.variables[in_ecmwf_lon_var][:] + 180) % 360 - 180
    # assume [-90, 90]
    ecmwf_lat = data_ecmwf_nc.variables[in_ecmwf_lat_var][:]
    data_ecmwf_nc.close()

    rtree_create_weight_table(ecmwf_lat, ecmwf_lon,
                              in_catchment_shapefile, river_id,
                              in_connectivity_file, out_weight_table,
                              file_geodatabase, area_id)