Ejemplo n.º 1
0
def load_case(rain=True):
    cases_name = 't_model' if rain else 'feb15'
    scheme_id = conf.SCHEME_ID_MELT if rain else conf.SCHEME_ID_SNOW
    cases = multicase.read_cases(cases_name)
    c = cases.case[0]
    c.load_classification(scheme_id)
    return c
Ejemplo n.º 2
0
def init_cases(cases_id=None, season=''):
    """initialize cases data"""
    if cases_id is None:
        if season == 'snow':
            cases_id = CASES_SNOW
        elif season == 'rain':
            cases_id = CASES_RAIN
    cases = multicase.read_cases(cases_id)
    if cases.ml.astype(bool).all():
        cases = cases[cases['ml_ok'].fillna(0).astype(bool)]
    return cases
Ejemplo n.º 3
0
def init_data(cases_id, scheme_id, has_ml=False, use_cache=False, **kws):
    """initialize cases data"""
    if use_cache:
        cases_fname = 'cases_{}{}.pkl'.format(cases_id, scheme_id)
        cases_file = path.join(CACHE_DIR, cases_fname)
        cc_fname = 'cc_{}{}.pkl'.format(cases_id, scheme_id)
        cc_file = path.join(CACHE_DIR, cc_fname)
        if path.exists(cases_file) and path.exists(cc_file):
            print('Using cached profile data.')
            return pkl_load(cases_file), pkl_load(cc_file)
    cases = multicase.read_cases(cases_id)
    if has_ml:
        cases = cases[cases.ml_ok.astype(bool)]
    for i, c in cases.case.iteritems():
        c.load_classification(scheme_id)
    cases, cc = recase.combine_cases_t_thresh(cases)
    #cc = multicase.MultiCase.by_combining(cases, has_ml=has_ml, **kws)
    cc.load_classification(scheme_id)
    for i, c in cases.case.iteritems():
        c.load_classification(scheme_id)
    if use_cache:
        pkl_dump(cases, cases_file)
        pkl_dump(cc, cc_file)
    return cases, cc
Ejemplo n.º 4
0
# coding: utf-8

import matplotlib.pyplot as plt
from os import path
from radcomp.vertical import multicase
from scr_erad_cases import savedir

if __name__ == '__main__':
    plt.close('all')
    cases = multicase.read_cases('feb21')
    c = cases.case.iloc[0]
    fig, _ = c.plot(plot_fr=False, plot_t=False, plot_azs=False)
    fig.savefig(path.join(savedir, 'feb21.png'), bbox_inches='tight')
Ejemplo n.º 5
0
# coding: utf-8

from os import path

import matplotlib.pyplot as plt

from radcomp.tools import cloudnet
from radcomp.vertical import multicase

import conf

if __name__ == '__main__':
    plt.ion()
    plt.close('all')
    cases = multicase.read_cases('t_model')
    c = cases.case[0]
    c.load_model_temperature()
    #c.load_classification(conf.SCHEME_ID_MELT)
    c.load_model_data(variable='rh')
    params = ['zh', 'zdr', 'kdp', 'rh']
    fig, axarr = c.plot(plot_fr=False,
                        plot_t=False,
                        plot_azs=False,
                        t_contour_ax_ind=[0, 1, 2],
                        cmap='viridis',
                        params=params,
                        t_levels=(-20, -8, 0))
Ejemplo n.º 6
0
import matplotlib.pyplot as plt
from os import path
from radcomp.vertical import multicase  #, RESULTS_DIR
#from j24 import ensure_join
import conf

case_set_r = 'erad18_rain'
case_set_s = 'erad18_snow'
scheme_id_r = conf.SCHEME_ID_MELT
scheme_id_s = conf.SCHEME_ID_SNOW
savedir = conf.P1_FIG_DIR

if __name__ == '__main__':
    plt.close('all')
    plt.ion()
    cases_r = multicase.read_cases(case_set_r)
    cases_s = multicase.read_cases(case_set_s)
    for i, c in cases_r.case.iteritems():
        c.load_classification(scheme_id_r)
        fig, axarr = c.plot(n_extra_ax=0, plot_silh=False)  #, cmap='viridis')
        fig.set_size_inches(2.5, 4)
        axarr[-1].set_xticks(axarr[-1].get_xticks()[1::2])
        fig.savefig(path.join(savedir, 'hm_case.png'), bbox_inches='tight')
    for i, c in cases_s.case.iteritems():
        c.load_classification(scheme_id_s)
        fig, axarr = c.plot(n_extra_ax=0,
                            plot_silh=False,
                            plot_fr=False,
                            plot_azs=False)
        fig.set_size_inches(3.5, 4)
        #axarr[-1].set_xticks(axarr[-1].get_xticks()[0::2])
Ejemplo n.º 7
0
def cases_from_cases_set():
    """setup cases based on a cases list"""
    return multicase.read_cases('debug')
Ejemplo n.º 8
0
# coding: utf-8
"""script for debugging ML"""

import matplotlib.pyplot as plt

from radcomp.vertical import multicase

from conf import SCHEME_ID_MELT

name = 'mlt2_3eig10clus_pca'
#name = SCHEME_ID_MELT

if __name__ == '__main__':
    plt.close('all')
    cases = multicase.read_cases('ml_debug')
    c = cases.case[0]
    c.load_classification(name)
    c.plot(params=['ZH', 'zdr', 'RHO', 'MLI'], cmap='viridis')
Ejemplo n.º 9
0
def workflow(c, vpc_params, plot_kws={}, **kws):
    """training workflow"""
    vpc = classification.VPC(**vpc_params)
    c.vpc = vpc
    training(c, **kws)
    make_plots(vpc, **plot_kws)


if __name__ == '__main__':
    bracketing = False
    plt.ion()
    plt.close('all')
    cases_id = 'rain'
    #
    rain_season = cases_id in ('rain', )
    cases = multicase.read_cases(cases_id)
    if rain_season:
        cases = cases[cases['ml_ok'].fillna(0).astype(bool)]
    vpc_params = VPC_PARAMS_RAIN if rain_season else VPC_PARAMS_SNOW
    c = multicase.MultiCase.by_combining(cases, has_ml=rain_season)
    if bracketing:
        for n_clusters in np.arange(14, 20):
            vpc_params.update({'n_clusters': n_clusters})
            plot_kws = dict(plt_silh=False,
                            plt_sca=False,
                            plt_top=False,
                            save_plots=False)
            print(vpc_params)
            workflow(c, vpc_params, plot_kws=plot_kws)
    else:
        kws = dict(save_plots=True)