【GFZ】地磁指数与太阳指数

Washy
2024-09-27 / 1 评论 / 15 阅读 / 正在检测是否收录...

0 前言

介绍如何下载德国地学中心GFZ提供的地磁行星3小时Kp指数、相关地磁指数和太阳指数。

1 GFZ-FTP

1.1 Kp_ap_Ap_SN_F107

  • Python爬虫源码如下
import os
import socket

from ftplib import FTP
from ftplib import error_perm

##----------------------------------------------------------------------##
# INFO: ftp网站连接
##----------------------------------------------------------------------##
# Outputs:
#   ftp         - ftp根目录
##----------------------------------------------------------------------##
# author: Washy
# date: 2024/09/27
##----------------------------------------------------------------------##
def ftp_connect():
    # FTP站点
    host = 'ftp.gfz-potsdam.de'
    # 端口号
    port = 21
    # 文件夹路径
    folderpath = '/pub/home/obs/Kp_ap_Ap_SN_F107'

    ftp = FTP()
    ftp.encoding = 'utf-8'

    try:
        ftp.connect(host, port)
        ftp.login()
        ftp.cwd(folderpath)
    except(socket.error, socket.gaierror):  # ftp 连接错误
        print("ERROR: cannot connect [{}:{}]".format(host, port))
        return None
    except error_perm:  # 用户登录认证错误
        print("ERROR: user Authentication failed ")
        return None

    return ftp

def is_ftp_file(ftp_conn, filename):
    try:
        if filename in ftp_conn.nlst(os.path.dirname(filename)):
            return True
        else:
            return False
    except error_perm:
        return False

# 连接服务器
ftp = ftp_connect()
# 需要下载的文件名
filename = "Kp_ap_Ap_SN_F107_2024.txt"
# 下载文件
with open(filename, 'wb') as f:
    ftp.retrbinary('RETR ' + filename, f.write, 1024)
# 断开服务器
ftp.close()
  • 下载的数据格式示例如下
# PURPOSE: This file distributes the geomagnetic planetary three-hour index Kp and associated geomagnetic indices as well as relevant solar indices.
# LICENSE: CC BY 4.0, except for the sunspot numbers contained in this file, which have the CC BY-NC 4.0 license
# SOURCE: Geomagnetic Observatory Niemegk, GFZ German Research Centre for Geosciences
# PLEASE CITE: Matzka, J., Stolle, C., Yamazaki, Y., Bronkalla, O. and Morschhauser, A., 2021. The geomagnetic Kp index 
# and derived indices of geomagnetic activity. Space Weather, https://doi.org/10.1029/2020SW002641
#
# Kp, ap and Ap
# The three-hourly equivalent planetary amplitude ap is derived from Kp and the daily equivalent planetary amplitude Ap is the daily mean of ap.
# Kp is unitless. Ap and ap are unitless and can be multiplied by 2 nT to yield the average geomagnetic disturbance at 50 degree geomagnetic latitude.
# Kp, ap and Ap were introduced by Bartels (1949, 1957) and are produced by Geomagnetic Observatory Niemegk, GFZ German Research Centre for Geosciences.
# Described in: Matzka et al. (2021), see reference above.
# Data publication: Matzka, J., Bronkalla, O., Tornow, K., Elger, K. and Stolle, C., 2021. Geomagnetic Kp index. V. 1.0. GFZ Data Services, 
# https://doi.org/10.5880/Kp.0001
# Note: the most recent values are nowcast values and will be replaced by definitive values as soon as they become available.
# 
# International Sunspot Number SN
# The international sunspot number SN (written with subscript N) is given as the daily total sunspot number version 2.0 introduced in 2015.
# The sunspot data is available under the licence CC BY-NC 4.0 from WDC-SILSO, Royal Observatory of Belgium, Brussels. Described in:
# Clette, F., Lefevre, L., 2016. The New Sunspot Number: assembling all corrections. Solar Physics, 291, https://doi.org/10.1007/s11207-016-1014-y 
# Note: the most recent values are preliminary and replaced by definitive values as soon as they become available.
#
# F10.7 Solar Radio Flux
# Local noon-time observed (F10.7obs) and adjusted (F10.7adj) solar radio flux F10.7 in s.f.u. (10^-22 W m^-2 Hz^-1) is provided by 
# Dominion Radio Astrophysical Observatory and Natural Resources Canada.
# Described in: Tapping, K.F., 2013. The 10.7 cm solar radio flux (F10.7). Space Weather, 11, 394-406, https://doi.org/10.1002/swe.20064 
# Note: For ionospheric and atmospheric studies the use of F10.7obs is recommended.
# 
# Short file description (for a detailed file description, see Kp_ap_Ap_SN_F107_format.txt):
# 40 header lines, all starting with #
# ASCII, blank separated and fixed length, missing data indicated by -1.000 for Kp, -1 for ap and SN, -1.0 for F10.7
# YYYY MM DD is date of UT day, days is days since 1932-01-01 00:00 UT to start of UT day, days_m is days since 1932-01-01 00:00 UT to midday of UT day
# BSR is Bartels solar rotation number, dB is day within BSR 
# Kp1 to Kp8 (Kp for the eight eighth of the UT day), ap1 to ap8 (ap for the eight eighth of the UT day), Ap, SN, F10.7obs, F10.7adj
# D indicates if the Kp and SN values are definitive or preliminary. D=0: Kp and SN preliminary; D=1: Kp definitive, SN preliminary; D=2 Kp and SN definitive
#
#
# The format for each line is (i stands for integer, f for float):
#iii ii ii iiiii fffff.f iiii ii ff.fff ff.fff ff.fff ff.fff ff.fff ff.fff ff.fff ff.fff iiii iiii iiii iiii iiii iiii iiii iiii  iiii iii ffffff.f ffffff.f i
# The parameters in each line are:
#YYY MM DD  days  days_m  Bsr dB    Kp1    Kp2    Kp3    Kp4    Kp5    Kp6    Kp7    Kp8  ap1  ap2  ap3  ap4  ap5  ap6  ap7  ap8    Ap  SN F10.7obs F10.7adj D
2024 01 01 33603 33603.5 2596 25  0.667  0.333  0.667  1.333  2.000  3.000  3.333  4.000    3    2    3    5    7   15   18   27    10  54    135.7    131.2 1
2024 01 02 33604 33604.5 2596 26  2.667  2.333  0.667  2.000  2.333  2.667  2.000  0.667   12    9    3    7    9   12    7    3     8  66    142.1    137.4 1
2024 01 03 33605 33605.5 2596 27  2.667  2.667  1.000  1.667  1.667  2.667  3.333  3.000   12   12    4    6    6   12   18   15    11  57    140.2    135.5 1
2024 01 04 33606 33606.5 2597  1  1.333  0.667  1.667  0.667  0.667  1.333  1.000  2.667    5    3    6    3    3    5    4   12     5  98    125.8    121.6 1
2024 01 05 33607 33607.5 2597  2  2.000  1.667  0.333  1.000  1.333  1.667  0.333  0.333    7    6    2    4    5    6    2    2     4 117    152.7    147.6 1
1

评论 (1)

昵称
邮箱
网址
取消
  1. 头像

    [...]爬虫[...]

    回复