code: def get_weather(conn, geometry, year):
      r
      rename_dc = {
          'ASWDIFD_S': 'dhi',
          'ASWDIR_S': 'dirhi',
          'PS': 'pressure',
          'T_2M': 'temp_air',
          'WSS_10M': 'v_wind',
          'Z0': 'z0'}
  
      if geometry.geom_type in ['Polygon', 'MultiPolygon']:
          # Create MultiWeather
          # If polygon covers only one data set switch to SingleWeather
          sql_part = """
              SELECT sp.gid, ST_AsText(point.geom), ST_AsText(sp.geom)
              FROM coastdat.cosmoclmgrid AS sp
              JOIN coastdat.spatial AS point ON (sp.gid=point.gid)
              WHERE st_intersects(ST_GeomFromText('{wkt}',4326), sp.geom)
              """.format(wkt=geometry.wkt)
          df = fetch_raw_data(sql_weather_string(year, sql_part), conn, geometry)
          obj = create_multi_weather(df, rename_dc)
      elif geometry.geom_type == 'Point':
          # Create SingleWeather
          sql_part = """
              SELECT sp.gid, ST_AsText(point.geom), ST_AsText(sp.geom)
              FROM coastdat.cosmoclmgrid AS sp
              JOIN coastdat.spatial AS point ON (sp.gid=point.gid)
              WHERE st_contains(sp.geom, ST_GeomFromText('{wkt}',4326))
              """.format(wkt=geometry.wkt)
          df = fetch_raw_data(sql_weather_string(year, sql_part), conn, geometry)
          obj = create_single_weather(df, rename_dc)
      else:
          logging.error('Unknown geometry type: {0}'.format(geometry.geom_type))
          obj = None
      return obj
docs: r"""
      Get the weather data for the given geometry and create an oemof
      weather object.