Windy Community
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    • Register
    • Login

    No data returned

    Windy API v4
    1
    1
    37
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kinhbachusK
      kinhbachus | Premium
      last edited by

      import requests
      import pandas as pd
      import numpy as np
      from shapely.geometry import Point
      import random
      import time
      from datetime import datetime

      Tọa độ khu vực mới (bounding box)

      min_lat = 21.457803 # Điểm dưới cùng bên phải
      max_lat = 22.856127 # Điểm trên cùng bên trái
      min_lon = 101.990717 # Điểm trên cùng bên trái
      max_lon = 104.447468 # Điểm dưới cùng bên phải

      print(f"Bounding box (lat/lon): min_lon={min_lon}, min_lat={min_lat}, max_lon={max_lon}, max_lat={max_lat}")

      API Key mới của Point Forecast API

      api_key = "*********************************"

      Mốc thời gian: 19/04/2025 00:00:00 UTC

      target_timestamp = 1745193600000 # Timestamp (mili-giây) cho 19/04/2025 00:00:00 UTC

      Tạo 200 điểm nằm trong khu vực

      target_points = 200
      points_in_boundary = []

      Chia bounding box thành lưới thưa

      grid_size = int(np.sqrt(target_points))
      lat_steps = np.linspace(min_lat, max_lat, grid_size)
      lon_steps = np.linspace(min_lon, max_lon, grid_size)
      grid_cells = [(lat, lon) for lat in lat_steps for lon in lon_steps]
      points_per_cell = max(1, target_points // len(grid_cells))

      Tạo ngẫu nhiên các điểm trong mỗi ô

      for lat_center, lon_center in grid_cells:
      if len(points_in_boundary) >= target_points:
      break
      for _ in range(points_per_cell):
      if len(points_in_boundary) >= target_points:
      break
      lat = lat_center + random.uniform(-0.05, 0.05)
      lon = lon_center + random.uniform(-0.05, 0.05)
      points_in_boundary.append((lat, lon))

      Nếu chưa đủ 200 điểm, tạo thêm ngẫu nhiên

      while len(points_in_boundary) < target_points:
      lat = random.uniform(min_lat, max_lat)
      lon = random.uniform(min_lon, max_lon)
      points_in_boundary.append((lat, lon))

      print(f"Số điểm được tạo: {len(points_in_boundary)}")

      Danh sách để lưu dữ liệu

      all_data = []

      Gửi yêu cầu cho từng điểm trong khu vực

      for lat, lon in points_in_boundary:
      if not (-90 0:
      df.to_csv("precipitation_data_200_points_20250419.csv", index=False)
      print("Dữ liệu đã được lưu vào file precipitation_data_200_points_20250419.csv")
      else:
      print("Không có dữ liệu nào được thu thập tại timestamp chính xác.")

      Nếu số lượng điểm không đủ 200, in thông báo

      if len(df) != target_points:
      print(f"Chỉ có {len(df)} điểm được thu thập tại timestamp {target_timestamp}. Bạn có thể thử lại với thời gian hoặc mô hình khác.")

      I have a problem where the code is not sending data back.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
      NodeBB & contributors, OSM & contributors, HERE maps
      Terms of Use     Privacy Policy