Ejemplo n.º 1
0
        lat = tmp[:, :, 1]
        lon = tmp[:, :, 0]

        #Exclude areas outside the radar domain.
        radar_mask = cmf.distance_range_mask(lon_radar, lat_radar, radar_range,
                                             lon, lat)

    #=========================================================
    #  READ THE DATA
    #=========================================================

    my_file = basedir + '/' + my_exp + '/time_mean/' + filetype + '/update_comp_meandiff_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(
        nbv) + '_obs_inc_' + str(obs_increment) + '_rmse' + '.grd'

    rmse[my_exp] = np.nanmean(
        np.delete(ctlr.read_data(my_file, ctl_dict, undef2nan=True), 4, 2), 2)

    rmse[my_exp][np.isnan(rmse[my_exp])] = undef
    rmse[my_exp] = cf.gaussian_filter(field0=rmse[my_exp],
                                      dx=1.0,
                                      sigma=sigma_smooth,
                                      nx=nx,
                                      ny=ny,
                                      undef=undef)
    rmse[my_exp][rmse[my_exp] == undef] = np.nan

    print('RMSE values')
    print(my_exp)
    print(np.min(rmse[my_exp]), np.max(rmse[my_exp]))

    my_file = basedir + '/' + my_exp + '/time_mean/' + filetype + '/' + '/moment0001_mean.grd'
      while ( ctime <= etime )  :

         print( ctime )

         print ( 'Reading data')

         #=========================================================
         #  READ THE DATA
         #=========================================================

         my_file=basedir + '/' + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/' + filetype + '/update_comp_meandiff_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'

         print('Reading update comparisson for ',var_obs,' and ',var_upd)

         #Read all the variables and levels at once
         tmp_parameter[:,:,:,it] = np.squeeze( ctlr.read_data(  my_file , ctl_dict , undef2nan = True ) )

         #print( np.nanmin(tmp_parameter[:,:,:,it]) , np.nanmax( tmp_parameter[:,:,:,it] ) )

         ctime = ctime + delta
 
         it = it + 1

      print ( "Finish time loop" )

      rmse = np.sqrt( np.squeeze( np.nanmean( np.power( tmp_parameter , 2) , 3 ) ) )
      bias = np.squeeze( np.nanmean( tmp_parameter , 3 ) )

      print('RMSE ', np.nanmin(rmse) , np.nanmax(rmse) )
      print('BIAS ', np.nanmin(bias) , np.nanmax(bias) )
Ejemplo n.º 3
0
#  READ THE DATA
#=========================================================

parameter_5MIN = []
parameter_30SEC = []

for iv, my_var in enumerate(obs_variables):

    var_obs = obs_variables[iv]
    var_upd = upd_variables[iv]

    my_file = basedir + '/LE_D1_1km_5min/time_mean/guesgp/update_comp_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(
        nbv) + '_obs_inc_' + str(obs_increment[iv]) + '_kld' + '.grd'
    parameter_5MIN.append(
        np.nanmean(
            np.delete(ctlr.read_data(my_file, ctl_dict, undef2nan=False), 4,
                      2), 2))
    my_file = basedir + '/LE_D1_1km_30sec/time_mean/guesgp/update_comp_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(
        nbv) + '_obs_inc_' + str(obs_increment[iv]) + '_kld' + '.grd'
    parameter_30SEC.append(
        np.nanmean(
            np.delete(ctlr.read_data(my_file, ctl_dict, undef2nan=False), 4,
                      2), 2))

    parameter_5MIN[iv] = cf.gaussian_filter(field0=parameter_5MIN[iv],
                                            dx=1.0,
                                            sigma=sigma_smooth,
                                            nx=nx,
                                            ny=ny,
                                            undef=undef)
    parameter_30SEC[iv] = cf.gaussian_filter(field0=parameter_30SEC[iv],
Ejemplo n.º 4
0
            print(ctime)

            print('Reading data')

            #=========================================================
            #  READ THE DATA
            #=========================================================

            my_file = basedir + my_exp + '/' + ctime.strftime(
                "%Y%m%d%H%M%S"
            ) + '/' + my_file_type + '/' + '/' + file_name + '.grd'

            #Read all the variables and levels at once
            tmp_parameter[:, :, :, it] = np.squeeze(
                ctlr.read_data(my_file, ctl_dict, undef2nan=True))

            print(np.nanmin(tmp_parameter[:, :, :, it]),
                  np.nanmax(tmp_parameter[:, :, :, it]))

            ctime = ctime + delta

            it = it + 1

        print("Finish time loop")

        parameter = np.squeeze(np.nanmean(tmp_parameter, 3))

        print(np.nanmin(parameter), np.nanmax(parameter))

        my_file = outputdir + '/' + file_name + '_mean' + '.grd'
Ejemplo n.º 5
0
            print(ctime)

            print('Reading data')

            #=========================================================
            #  READ THE DATA
            #=========================================================

            my_file = basedir + my_exp + '/' + ctime.strftime(
                "%Y%m%d%H%M%S"
            ) + '/' + my_file_type + '/' + '/' + file_name + '.grd'

            #Read all the variables and levels at once
            tmp_parameter[:, :, :,
                          it] = np.squeeze(ctlr.read_data(my_file, ctl_dict))

            print(np.min(tmp_parameter[:, :, :, it]),
                  np.max(tmp_parameter[:, :, :, it]))

            ctime = ctime + delta

            it = it + 1

        print("Finish time loop")

        tmp_parameter[tmp_parameter == undef] = np.nan

        print(np.nanmin(tmp_parameter), np.nanmax(tmp_parameter))

        parameter = np.squeeze(np.nanmean(tmp_parameter, 3))
      kld_norain = np.zeros((nz,ntimes))

      while ( ctime <= etime )  :

         print( ctime )

         print ('Reading data')

         #=========================================================
         #  READ THE DATA
         #=========================================================

         my_file=basedir + '/' + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/' + filetype + '/update_comp_meandiff_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'

         #Read all the variables and levels at once
         parameter = ctlr.read_data(  my_file , ctl_dict , undef2nan = True ) 

         my_file=basedir + '/' + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/' + filetype + '/update_comp_kld_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'

         #Read all the variables and levels at once
         kld = ctlr.read_data(  my_file , ctl_dict , undef2nan = True )

         my_file=basedir + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/guesgp/moment0001.grd'       

         max_dbz =  np.squeeze( np.nanmax( ctlr.read_data_grads(  my_file , ctl_dict_2 , undef2nan = True )['dbz']  , 2 ) )

         #Several mask can be defined here.

         rain_mask = np.logical_and( max_dbz > rain_threshold , radar_mask )

         norain_mask = np.logical_and( max_dbz < norain_threshold , radar_mask )
Ejemplo n.º 7
0
            print(ctime)

            print('Reading data')

            #=========================================================
            #  READ THE DATA
            #=========================================================

            my_file = basedir + my_exp + '/' + ctime.strftime(
                "%Y%m%d%H%M%S"
            ) + '/' + my_file_type + '/' + '/' + file_name + '.grd'

            #Read all the variables and levels at once
            tmp_parameter[:, :, :, it] = np.squeeze(
                ctlr.read_data(my_file, ctl_dict, undef2nan=True))

            my_file = basedir + my_exp + '/' + ctime.strftime(
                "%Y%m%d%H%M%S") + '/guesgp/moment0001.grd'

            gues = np.squeeze(ctlr.read_data(my_file, ctl_dict,
                                             undef2nan=True))

            my_file = basedir + my_exp + '/' + ctime.strftime(
                "%Y%m%d%H%M%S") + '/analgp/moment0001.grd'

            anal = np.squeeze(ctlr.read_data(my_file, ctl_dict,
                                             undef2nan=True))

            #Remove the grid points in which the prior has not been updated by the observations.
            tmp_parameter[:, :, :, it][np.abs(gues - anal) < 1.0e-7] = np.nan
Ejemplo n.º 8
0
         #Read all the variables and levels at once
         ensemble_mean = ctlr.read_data_grads(  my_file , ctl_dict_2 , undef2nan = True ) 

         max_dbz = np.squeeze( np.nanmax( np.delete( ensemble_mean['dbz'] , 4 , 2) , 2 ) )

         rain_mask = np.logical_and( max_dbz > rain_threshold , radar_mask )

         norain_mask = np.logical_and( max_dbz < norain_threshold , radar_mask )

         #=========================================================
         #  READ THE DATA
         #=========================================================

         my_file=basedir + '/' + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/guesgp/update_comp_meandiff_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'
         update_mean_diff = np.squeeze( ctlr.read_data(  my_file , ctl_dict , undef2nan = True ) )
         my_file=basedir + '/' + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/guesgp/update_comp_updated_mean_kf_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'
         update_mean_kf = np.squeeze( ctlr.read_data(  my_file , ctl_dict , undef2nan = True ) )
         my_file=basedir + '/' + my_exp + '/' + ctime.strftime("%Y%m%d%H%M%S") + '/guesgp/update_comp_kld_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'
         update_kld = np.squeeze( ctlr.read_data(  my_file , ctl_dict , undef2nan = True ) )
         
         update_mean_bias = np.copy(update_mean_diff)
         
         update_mean_diff = np.power( np.delete( update_mean_diff , 4 ,2 )  , 2 )

         update_mean_kf   = np.power( np.delete( update_mean_kf - np.squeeze(ensemble_mean[ var_upd ]) , 4 ,2 ) , 2 )

         update_kld = np.delete( update_kld , 4 , 2 )

         update_mean_diff[ update_mean_diff == 0.0 ] = np.nan
         update_mean_kf[ update_mean_kf == 0.0 ] = np.nan
   mean_diff = []
   kld       = []
   
   
   my_file=basedir + expnames[icase] + ctimes[icase].strftime("%Y%m%d%H%M%S") + '/guesgp/moment0001.grd'

   m01=ctlr.read_data_grads(my_file,ctl_dict_2,masked=False,undef2nan=True)

   for iv,my_var in enumerate( obs_variables ) :

      var_obs = obs_variables[iv]
      var_upd = upd_variables[iv]
                                                                                                                 
      my_file=basedir + '/' + expnames[icase] + '/' + ctimes[icase].strftime("%Y%m%d%H%M%S") +'/guesgp/update_comp_meandiff_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv])  + '.grd'
      mean_diff.append( np.delete( ctlr.read_data(my_file,ctl_dict,undef2nan=False) , 4 , 2 ) )
      my_file=basedir + '/' + expnames[icase] + '/' + ctimes[icase].strftime("%Y%m%d%H%M%S") +'/guesgp/update_comp_kld_vobs_' + var_obs + '_upd_obs_' + var_upd + '_ens_size_' + str(nbv) + '_obs_inc_' + str(obs_increment[iv]) + '.grd'
      kld.append( np.delete( ctlr.read_data(my_file,ctl_dict,undef2nan=False) , 4 , 2 ) )
      
      print(var_obs,var_upd,np.min(mean_diff[iv]),np.max(mean_diff[iv]))
      print(var_obs,var_upd,np.min(kld[iv]),np.max(kld[iv]))
      
      for ii in range( mean_diff[iv].shape[2] ) :

         mean_diff[iv][:,:,ii][np.logical_not( mask )]=np.nan
         kld[iv][:,:,ii][np.logical_not( mask )]=np.nan
         
      mean_diff[iv] = np.squeeze( np.nanmean( mean_diff[iv] , 1 ) )
      kld[iv]       = np.squeeze( np.nanmean( kld[iv] , 1 ) )
         
   dbz=np.squeeze(np.delete(m01['dbz'],4,2))