コード例 #1
0
            print("-h/--help     : print this help data")
            print(
                "-v/--verbose  : print logging output to shell for debugging")
            print("-------------------------------------")
            print("EXAMPLE USAGE:")
            print("  Most basic:")
            print("    python predstorm_l5.py")
            print("    --> See results/ folder for output.")
            print(
                "-----------------------------------------------------------------"
            )
            print("")
            sys.exit()

    # INITIATE LOGGING:
    logger = ps.init_logging(verbose=verbose)

    # CHECK OUTPUT DIRECTORIES AND REQUIRED FILES:
    outputdirectory = 'results'
    # Check if directory for output exists (for plots and txt files)
    if os.path.isdir(outputdirectory) == False: os.mkdir(outputdirectory)
    # Make directory for savefiles
    if os.path.isdir(outputdirectory + '/savefiles') == False:
        os.mkdir(outputdirectory + '/savefiles')
    # Check if directory for beacon data exists:
    if os.path.isdir('data') == False:
        logger.info("Creating folder data for data downloads...")
        os.mkdir('data')

    # Closes all plots
    plt.close('all')
コード例 #2
0
ファイル: plot.py プロジェクト: zhaomingxian/PREDSTORM
def plot_all(timestamp=None, plotdir="plots", download=True):
    """Makes plots of a time range ending with timestamp using all functions."""

    import predstorm as ps

    if not os.path.isdir(plotdir):
        os.mkdir(plotdir)

    if timestamp == None:
        timestamp = datetime.utcnow()
    look_back = 30
    lag_L1, lag_r = ps.get_time_lag_wrt_earth(timestamp=timestamp,
                                              satname='STEREO-A')
    est_timelag = lag_L1 + lag_r

    logger = ps.init_logging(verbose=True)
    logger.info("Plotting all plots...")

    # STEREO DATA
    stam = ps.get_stereoa_data_beacon(
        starttime=timestamp - timedelta(days=look_back + est_timelag + 0.5),
        endtime=timestamp)
    stam.load_positions(
        'data/positions/STEREOA-pred_20070101-20250101_HEEQ_6h.p')
    # DSCOVR DATA
    dism = ps.get_dscovr_data_all(P_filepath="data/dscovrarchive/*",
                                  M_filepath="data/dscovrarchive/*",
                                  starttime=timestamp -
                                  timedelta(days=look_back),
                                  endtime=timestamp,
                                  download=download)
    dism.load_positions('data/positions/Earth_20000101-20250101_HEEQ_6h.p',
                        l1_corr=True)
    # KYOTO DST
    dst = ps.get_past_dst(filepath="data/dstarchive/WWW_dstae00019594.dat",
                          starttime=timestamp - timedelta(days=look_back),
                          endtime=timestamp)

    logger.info(
        "\n-------------------------\nDst comparison\n-------------------------"
    )
    outfile = os.path.join(plotdir,
                           "dst_prediction_{}day_plot.png".format(look_back))
    plot_dst_comparison(stam,
                        dism,
                        dst,
                        timestamp=timestamp,
                        look_back=look_back,
                        outfile=outfile)

    logger.info(
        "\n-------------------------\nSTEREO-A vs DSCOVR\n-------------------------"
    )
    outfile = os.path.join(
        plotdir, "stereoa_vs_dscovr_{}day_plot.png".format(look_back))
    plot_stereo_dscovr_comparison(stam,
                                  dism,
                                  dst,
                                  timestamp=timestamp,
                                  look_back=look_back,
                                  outfile=outfile)

    logger.info(
        "\n-------------------------\nPredicted indices\n-------------------------"
    )
    outfile = os.path.join(plotdir, "indices_{}day_plot.png".format(look_back))
    plot_indices(dism,
                 timestamp=timestamp,
                 look_back=look_back,
                 outfile=outfile)
コード例 #3
0
ファイル: predstorm_l5.py プロジェクト: IWF-helio/PREDSTORM
            print("-h/--help     : print this help data")
            print("-v/--verbose  : print logging output to shell for debugging")
            print("-------------------------------------")
            print("EXAMPLE USAGE:")
            print("  Most basic:")
            print("    python predstorm_l5.py")
            print("    --> See results/ folder for output.")
            print("-----------------------------------------------------------------")
            print("")
            sys.exit()

    # DEFINE OUTPUT DIRECTORIES:
    outputdirectory='results'
    # Check if directory for output exists (for plots and txt files)
    if os.path.isdir(outputdirectory) == False: os.mkdir(outputdirectory)
    # Make directory for savefiles
    if os.path.isdir(outputdirectory+'/savefiles') == False:
        os.mkdir(outputdirectory+'/savefiles')
    # Check if directory for beacon data exists
    if os.path.isdir('sta_beacon') == False: os.mkdir('sta_beacon')

    # INITIATE LOGGING:
    logger = ps.init_logging(verbose=verbose)

    # Closes all plots
    plt.close('all')

    main()


コード例 #4
0
def plot_all(timestamp=None, plotdir="plots", download=True):
    """Makes plots of a time range ending with timestamp using all functions."""

    if not os.path.isdir(plotdir):
        os.mkdir(plotdir)

    if timestamp == None:
        timestamp = datetime.utcnow()

    from datetime import datetime, timedelta
    import predstorm as ps
    import os
    import heliosat

    logger = ps.init_logging(verbose=True)
    plotdir = "plots"

    timestamp = datetime(2019, 8, 8) - timedelta(
        days=26 *
        2)  # datetime.utcnow() - timedelta(days=180) # datetime(2019,6,23)
    look_back = 26
    lag_L1, lag_r = ps.get_time_lag_wrt_earth(timestamp=timestamp,
                                              satname='STEREO-A')
    est_timelag = lag_L1 + lag_r
    logger.info("Plotting all plots...")

    # STEREO DATA
    stam = ps.get_stereo_beacon_data(
        starttime=timestamp - timedelta(days=look_back + est_timelag + 0.5),
        endtime=timestamp)
    stam = stam.interp_nans(keys=['time'])
    stam.load_positions()
    # DSCOVR DATA
    if timestamp < datetime(2019, 6, 23):
        dism = ps.get_dscovr_data(starttime=timestamp -
                                  timedelta(days=look_back),
                                  endtime=timestamp)
    else:
        dism = ps.get_omni_data(starttime=timestamp -
                                timedelta(days=look_back),
                                endtime=timestamp)
        dism.h['HeliosatObject'] = heliosat.DSCOVR()
    dism.load_positions(l1_corr=True)
    # KYOTO DST
    dst = ps.get_omni_data(starttime=timestamp - timedelta(days=look_back),
                           endtime=timestamp,
                           download=False)
    # dst = ps.get_past_dst(filepath="data/dstarchive/WWW_dstae00019594.dat",
    #                       starttime=timestamp-timedelta(days=look_back),
    #                       endtime=timestamp)

    # PERSISTENCE MODEL
    t_syn = 26.27
    if timestamp < datetime(2019, 6, 10):
        dpmm = ps.get_dscovr_data(starttime=timestamp - timedelta(days=t_syn) -
                                  timedelta(days=look_back),
                                  endtime=timestamp - timedelta(days=t_syn))
    else:
        dpmm = ps.get_omni_data(starttime=timestamp - timedelta(days=t_syn) -
                                timedelta(days=look_back),
                                endtime=timestamp - timedelta(days=t_syn))
        dpmm.h['HeliosatObject'] = heliosat.DSCOVR()
    dpmm['time'] = dpmm['time'] + t_syn

    outfile = os.path.join(plotdir, "all_dst_{}day_plot.png".format(look_back))
    ps.plot.plot_dst_vs_persistence_model(stam,
                                          dism,
                                          dpmm,
                                          dst,
                                          look_back=look_back,
                                          timestamp=timestamp,
                                          outfile=outfile)

    logger.info(
        "\n-------------------------\nDst comparison\n-------------------------"
    )
    outfile = os.path.join(plotdir,
                           "dst_prediction_{}day_plot.png".format(look_back))
    plot_dst_comparison(stam,
                        dism,
                        dst,
                        timestamp=timestamp,
                        look_back=look_back,
                        outfile=outfile)

    logger.info(
        "\n-------------------------\nSTEREO-A vs DSCOVR\n-------------------------"
    )
    outfile = os.path.join(
        plotdir, "stereoa_vs_dscovr_{}day_plot.png".format(look_back))
    plot_stereo_dscovr_comparison(stam,
                                  dism,
                                  dst,
                                  timestamp=timestamp,
                                  look_back=look_back,
                                  outfile=outfile)

    logger.info(
        "\n-------------------------\nPredicted indices\n-------------------------"
    )
    outfile = os.path.join(plotdir, "indices_{}day_plot.png".format(look_back))
    plot_indices(dism,
                 timestamp=timestamp,
                 look_back=look_back,
                 outfile=outfile)
コード例 #5
0
        HEEQ_to_HEE_matrix=np.dot(S1, S2)
        #convert HEEQ components to HEE
        HEEQ=np.matrix([[heeq_bx[i]],[heeq_by[i]],[heeq_bz[i]]]) 
        HEE=np.dot(HEEQ_to_HEE_matrix,HEEQ)
        #change of sign HEE X / Y to GSE is needed
        bxgse[i]=-HEE.item(0)
        bygse[i]=-HEE.item(1)
        bzgse[i]=HEE.item(2)

    return (bxgse,bygse,bzgse)



######################################## MAIN PROGRAM ####################################

logger = ps.init_logging(verbose=True)

AU = 149597870.700 #AU in km
make_plots = False

#closes all plots
plt.close('all')

print()
print('PREDSTORM L1 solar wind forecasting. ')
print('Error estimation using STEREO-B data')
print()
print('Helio group, IWF Graz, last update June 2019.')


##########################################################################################