Changeset 2826 in lmdz_wrf for trunk/tools
- Timestamp:
- Apr 29, 2020, 3:26:57 PM (5 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var.py
r2795 r2826 327 327 'merge_files', \ 328 328 'model_characteristics', 'netcdf_concatenation', 'netcdf_fold_concatenation', \ 329 'netcdf_fold_concatenation_HMT', 'netcdf_fold_slice_concatenation_HMT'] 329 'netcdf_fold_concatenation_HMT', 'netcdf_fold_slice_concatenation_HMT', \ 330 'statcompare_files'] 330 331 331 332 ####### ###### ##### #### ### ## # … … 567 568 ncvar.splitfile_dim(opts.values, opts.ncfile, opts.varname) 568 569 elif oper == 'statcompare_files': 569 ncvar.statcompare_files(opts.values )570 ncvar.statcompare_files(opts.values, opts.ncfile, opts.varname) 570 571 elif oper == 'subbasin': 571 572 ncvar.subbasin(opts.values, opts.ncfile) -
trunk/tools/nc_var_tools.py
r2825 r2826 8640 8640 #setvar_asciivalues('obstimes.inf', 'obs/re_project_accumulated-1h_PRCP.nc', 'time') 8641 8641 8642 def statcompare_files(values ):8642 def statcompare_files(values, ncfile, varname): 8643 8643 """ Python script to statistically compare two different files 8644 values= [file1]:[var1],[file2][var2] 8645 [file1/2]: files to compare any diferent would be [file1]-[file2] 8646 [var1/2]: variable in file1/2 to compare 8644 values= [kindstats],[flavour],[outfile] 8645 [kindstats]: kind of statisitcs to compute 8646 'diffstats': statistics among differences between variables from each file 8647 'directstats': direct statistics of the fields of each file 8648 [flavour]: 'temporal', 'spatial', 'both', or 'None' kind of statistics 8649 [outfile]: whether an output file should be written or not 8650 ncfile: [file1],[file2] 8651 varname: [var1]:[var2] ',' separated sorted list of variables to use for each 8652 file ('all' for all values from both files, names must agree between files) 8647 8653 """ 8648 8649 8654 fname = 'statcompare_files' 8655 8650 8656 ofile='statcompare_files.nc' 8651 8657 … … 8655 8661 quit() 8656 8662 8657 file1=values.split(',')[0].split(':')[0] 8658 var1=values.split(',')[0].split(':')[1] 8659 file2=values.split(',')[1].split(':')[0] 8660 var2=values.split(',')[1].split(':')[1] 8663 expectargs = '[kindtats],[flavour],[outfile]' 8664 gen.check_arguments(fname,values,expectargs,',') 8665 8666 kindstats = values.split(',')[0] 8667 flavour = values.split(',')[1] 8668 outfile = gen.Str_Bool(values.split(',')[2]) 8669 8670 file1 = ncfile.split(',')[0] 8671 file2 = ncfile.split(',')[1] 8672 if varname == 'all': 8673 var1 = 'all' 8674 var2 = 'all' 8675 else: 8676 var1 = 'values' 8677 var2 = 'values' 8678 varns1 = gen.str_list(varname.split(':')[0], ',') 8679 varns2 = gen.str_list(varname.split(':')[1], ',') 8661 8680 8662 8681 if not os.path.isfile(file1): … … 8667 8686 objnc1 = NetCDFFile(file1, 'r') 8668 8687 8669 if not objnc1.variables.has_key(var1): 8670 print errormsg 8671 print ' ' + fname + ': netCDF file "' + file1 + \ 8672 '" does not have variable "' + var1 + '" !!!!' 8673 quit(-1) 8688 if var1 == 'all': 8689 varns1 = objnc1.variables.keys() 8690 varns1.sort() 8691 8692 for var1 in varns1: 8693 if not objnc1.variables.has_key(var1): 8694 print errormsg 8695 print ' ' + fname + ': netCDF file "' + file1 + \ 8696 '" does not have variable "' + var1 + '" !!!!' 8697 quit(-1) 8674 8698 8675 8699 if not os.path.isfile(file2): … … 8680 8704 objnc2 = NetCDFFile(file2, 'r') 8681 8705 8682 if not objnc2.variables.has_key(var2): 8706 if var2 == 'all': 8707 varns2 = objnc2.variables.keys() 8708 varns2.sort() 8709 8710 for var2 in varns2: 8711 if not objnc2.variables.has_key(var2): 8712 print errormsg 8713 print ' ' + fname + ': netCDF file "' + file2 + \ 8714 '" does not have variable "' + var2 + '" !!!!' 8715 quit(-1) 8716 8717 # Comparing 8718 if outfile: 8719 objofile = NetCDFFile(ofile, 'w') 8720 8721 N1vars = len(varns1) 8722 N2vars = len(varns2) 8723 if N1vars != N2vars: 8683 8724 print errormsg 8684 print ' ' + fname + ': netCDF file "' + file2 + \ 8685 '" does not have variable "' + var2 + '" !!!!' 8725 print ' ' + fname + ": provided list of variables for each file differ !!" 8726 print ' amount of variables from file 1:', N1vars, 'file 2:', N2vars 8727 if N1vars > N2vars: 8728 print ' Vars provided: file1 file2 _______' 8729 for i in range(N2vars): 8730 print ' ',i, ':', varns1[i], varns2[i] 8731 print ' excess of variables for file1:', varns1[N2vars:N1vars] 8732 if N1vars > N2vars: 8733 print ' Vars provided: file1 file2 _______' 8734 for i in range(N1vars): 8735 print ' ',i, ':', varns1[i], varns2[i] 8736 print ' excess of variables for file2:', varns2[N1vars:N2vars] 8686 8737 quit(-1) 8687 8688 objvar1 = objnc1.variables[var1] 8689 objvar2 = objnc2.variables[var2] 8690 8691 Ndim1 = len(objvar1.shape) 8692 Ndim2 = len(objvar2.shape) 8693 8694 if Ndim1 != Ndim2: 8695 print errormsg 8696 print ' ' + fname + ' variable: "' + var1 + '" from file "' + file1 + \ 8697 '" does not have the same size:' , Ndim1, 'as variable: "' + var2 + \ 8698 '" from file "' + file2 + '": ',Ndim2 8699 quit(-1) 8738 8739 for iv in range(N1vars): 8740 var1 = varns1[iv] 8741 var2 = varns2[iv] 8742 8743 objvar1 = objnc1.variables[var1] 8744 objvar2 = objnc2.variables[var2] 8745 8746 Ndim1 = len(objvar1.shape) 8747 Ndim2 = len(objvar2.shape) 8748 8749 if Ndim1 != Ndim2: 8750 print errormsg 8751 print ' ' + fname + ' variable: "' + var1 + '" from file "' + file1 + \ 8752 '" does not have the same size:' , Ndim1, 'as variable: "' + var2 + \ 8753 '" from file "' + file2 + '": ',Ndim2 8754 quit(-1) 8700 8755 8701 dims1 = objvar1.shape 8702 dims2 = objvar2.shape 8703 8704 for iid in range(Ndim1): 8705 if dims1[iid] != dims2[iid]: 8706 print errormsg 8707 print ' ' + fname + ' shape:',iid,'is different between variables!!!' 8708 print ' dim_var1:', dims1[iid], 'dim_var2:', dims2[iid] 8709 print ' var1 shape:', dims1 8710 print ' var2 shape:', dims2 8711 quit(-1) 8712 8713 varvals1 = objvar1[:] 8714 varvals2 = objvar2[:] 8715 8716 if Ndim1 == 3: 8717 timecompare = stats_time2Dvars(varvals1,varvals2) 8718 spacecompare = stats_space2Dvars(varvals1,varvals2) 8719 8720 dimt = varvals1.shape[0] 8721 dimy = varvals1.shape[1] 8722 dimx = varvals1.shape[2] 8723 8724 # print 'bias std.dev. ___________________________________' 8725 # for it in range(dimt): 8726 # print it,':',spacecompare.bias[it],spacecompare.stdv1Sv2[it] 8727 # print 'global spatial correlation (% significance)______' 8728 # for it in range(dimt): 8729 # print it, ':', spacecompare.corr[it], '(', \ 8730 # (1.-spacecompare.p_value[it])*100.,')' 8731 # print 'spatial means temporal correlation:',spacecompare.meancorr,'(', \ 8732 # (1.-spacecompare.meanp_value)*100.,' % significance)' 8733 # print 'temporal means temporal correlation:',timecompare.meancorr,'(', \ 8734 # (1.-timecompare.meanp_value)*100.,' % significance)' 8735 8736 # print 'temporal bias map________________________________' 8737 # print timecompare.meanv1Sv2 8738 8739 # print 'temporal correlation map_________________________' 8740 # print timeecompare.corr 8741 8742 else: 8743 print errormsg 8744 print ' ' + fname + ' numbe of dimensions:' + Ndim1 + ' not ready!!!' 8745 quit(-1) 8746 8747 # Creation of results file 8748 ## 8749 objofile = NetCDFFile(ofile, 'w') 8750 8751 # Dimensions 8752 for dimn in objnc1.dimensions: 8753 dimobj = objnc1.dimensions[dimn] 8754 if dimobj.isunlimited(): 8755 print ' ' + fname + ': Unlimited dimension ' 8756 dimsize = None 8756 dims1 = objvar1.shape 8757 dims2 = objvar2.shape 8758 8759 for iid in range(Ndim1): 8760 if dims1[iid] != dims2[iid]: 8761 print errormsg 8762 print ' ' + fname + ' shape:',iid,'is different between variables!!!' 8763 print ' dim_var1:', dims1[iid], 'dim_var2:', dims2[iid] 8764 print ' var1 shape:', dims1 8765 print ' var2 shape:', dims2 8766 quit(-1) 8767 8768 varvals1 = objvar1[:] 8769 varvals2 = objvar2[:] 8770 8771 if flavour != 'None': 8772 if Ndim1 == 3: 8773 if flavour == 'temporal' or flavour == 'both': 8774 timecompare = gen.stats_time2Dvars(varvals1,varvals2) 8775 if flavour == 'spatial' or flavour == 'both': 8776 spacecompare = gen.stats_space2Dvars(varvals1,varvals2) 8777 8778 xdimn = objvar1.dimensions[2] 8779 ydimn = objvar1.dimensions[1] 8780 tdimn = objvar1.dimensions[0] 8781 8782 dimt = varvals1.shape[0] 8783 dimy = varvals1.shape[1] 8784 dimx = varvals1.shape[2] 8785 8786 else: 8787 print errormsg 8788 print ' ' + fname + ' number of dimensions:', Ndim1, ' not ready !!' 8789 quit(-1) 8790 8791 if outfile: 8792 # Dimensions 8793 for dimn in objnc1.dimensions: 8794 dimobj = objnc1.dimensions[dimn] 8795 if not gen.searchInlist(objofile.dimensions, dimn): 8796 if dimobj.isunlimited(): 8797 dimsize = None 8798 else: 8799 dimsize = len(dimobj) 8800 8801 newdim = objofile.createDimension(dimn, dimsize) 8802 8803 if kindstats == 'diffstats': 8804 # Variables 8805 varattr1 = objvar1.ncattrs() 8806 varattr2 = objvar2.ncattrs() 8807 if gen.searchInlist(varattr1, '_fillValue') or \ 8808 gen.searchInlist(varattr2, '_fillValue'): 8809 if gen.searchInlist(varattr1, '_fillValue'): 8810 fillval = objvar1.getncattr('_fillValue') 8811 if gen.searchInlist(varattr2, '_fillValue'): 8812 fillval = objvar2.getncattr('_fillValue') 8813 newvar = objofile.createVariable('diff'+var1, objvar1.dtype, \ 8814 objvar1.dimensions, fill_value=fillval) 8815 else: 8816 newvar = objofile.createVariable('diff'+var1, objvar1.dtype, \ 8817 objvar1.dimensions) 8818 for attrn in objvar1.ncattrs(): 8819 if attrn != '_fillValue': 8820 attrval = objvar1.getncattr(attrn) 8821 newattr = newvar.setncattr(attrn, attrval) 8822 newatrr = newvar.setncattr('difference', var1 + '-' + var2) 8823 newvar[:] = varvals1 - varvals2 8824 8825 # Statistical variables 8826 typvar = objvar1.dtype 8827 if typvar == type(int(1)): 8828 fillValue = gen.fillValueI 8829 elif typvar == type((1.)) or typvar == type(np.float(1.)) or \ 8830 typvar == type(np.float64(1.)) or typvar == type(np.float32(1.)): 8831 fillValue = gen.fillValueF 8832 else: 8833 print errormsg 8834 print ' ' + fname + ": variable type:", typvar, "of var '" + var1 + \ 8835 "' not ready !!" 8836 quit(-1) 8837 8838 vartype = objvar1.dtype 8839 varunits = objvar2.getncattr('units') 8840 8841 if flavour == 'temporal' or flavour == 'both': 8842 # temporal bias 8843 newvar = objofile.createVariable('t_bias_'+var1+'_'+var2, vartype, \ 8844 (ydimn, xdimn), fill_value = fillValue) 8845 newvar[:] = timecompare.bias 8846 newattr = basicvardef(newvar, 't_bias_'+var1+'_'+var2, \ 8847 'temporal bias between ' + var1 + '&' + var2, varunits) 8848 8849 # temporal Standard deviation 8850 newvar = objofile.createVariable('t_stddev_'+var1+'_'+var2, vartype,\ 8851 (ydimn, xdimn), fill_value = fillValue) 8852 newvar[:] = timecompare.stdv1Sv2 8853 newattr = basicvardef(newvar, 't_stddev_'+var1+'_'+var2, \ 8854 'temporal standard deviation between '+ var1+'&' + var2, varunits) 8855 8856 # t Correlation map 8857 newvar = objofile.createVariable('t_corr_'+var1+'_'+var2, vartype, \ 8858 (ydimn, xdimn), fill_value = fillValue) 8859 newvar[:] = timecompare.corr 8860 newattr = basicvardef(newvar, 't_corr_'+var1+'_'+var2, \ 8861 'temporal correlation between ' + var1 + '&' + var2, '-') 8862 8863 # t p-value map 8864 newvar= objofile.createVariable('t_p_value_'+var1+'_'+var2, vartype,\ 8865 (ydimn,xdimn), fill_value = fillValue) 8866 newvar[:] = timecompare.p_value 8867 newattr = basicvardef(newvar, 't_p_value_'+var1+'_'+var2, \ 8868 'temporal p_value between ' + var1 + '&' + var2, '-') 8869 8870 # t mean Correlation 8871 newvar = objofile.createVariable('t_mean_corr_'+var1+'_'+var2, 'f4') 8872 newvar[:] = timecompare.meancorr 8873 newattr = basicvardef(newvar, 't_mean_corr_'+var1+'_'+var2, \ 8874 'time mean values correlation between ' + var1 + '&' + var2, '-') 8875 8876 # t mean p-value 8877 newvar=objofile.createVariable('t_mean_p_value_'+var1+'_'+var2, 'f4') 8878 newvar[:] = timecompare.meanp_value 8879 newattr = basicvardef(newvar, 't_mean_p_value_'+var1+'_'+var2, \ 8880 'time mean p_value between ' + var1 + '&' + var2, '-') 8881 8882 objofile.sync() 8883 8884 if flavour == 'spatial' or flavour == 'both': 8885 # space bias 8886 newvar = objofile.createVariable('s_bias_'+var1+'_'+var2, vartype, \ 8887 (tdimn), fill_value = fillValue) 8888 newvar[:] = spacecompare.bias 8889 newattr = basicvardef(newvar, 's_bias_'+var1+'_'+var2, \ 8890 'spatial bias between ' + var1 + '&' + var2, varunits) 8891 8892 # space Standard deviation 8893 newvar = objofile.createVariable('s_stddev_'+var1+'_'+var2, vartype,\ 8894 (tdimn), fill_value = fillValue) 8895 newvar[:] = spacecompare.stdv1Sv2 8896 newattr = basicvardef(newvar, 's_stddev_'+var1+'_'+var2, \ 8897 'spatial standard deviation between '+ var1 + '&' + var2, varunits) 8898 8899 # s Correlation map 8900 newvar = objofile.createVariable('s_corr_'+var1+'_'+var2, vartype, \ 8901 (tdimn), fill_value = fillValue) 8902 newvar[:] = spacecompare.corr 8903 newattr = basicvardef(newvar, 's_corr_'+var1+'_'+var2, \ 8904 'spatial correlation between ' + var1 + '&' + var2, '-') 8905 8906 # s p-value map 8907 newvar= objofile.createVariable('s_p_value_'+var1+'_'+var2, vartype,\ 8908 (tdimn), fill_value = fillValue) 8909 newvar[:] = spacecompare.p_value 8910 newattr = basicvardef(newvar, 's_p_value_'+var1+'_'+var2, \ 8911 'spatial p_value between ' + var1 + '&' + var2, '-') 8912 8913 # s mean Correlation 8914 newvar = objofile.createVariable('s_mean_corr_'+var1+'_'+var2, 'f4') 8915 newvar[:] = spacecompare.meancorr 8916 newattr = basicvardef(newvar, 's_mean_corr_'+var1+'_'+var2, \ 8917 'space mean values correlation between ' + var1 + '&' + var2, '-') 8918 8919 # s mean p-value 8920 newvar= objofile.createVariable('s_mean_p_value_'+var1+'_'+var2,'f4') 8921 newvar[:] = spacecompare.meanp_value 8922 newattr = basicvardef(newvar, 's_mean_p_value_'+var1+'_'+var2, \ 8923 'space mean p_value between ' + var1 + '&' + var2, '-') 8924 8925 objofile.sync() 8926 8927 # Global attributes 8928 for attrn in objnc1.ncattrs(): 8929 attrval = objnc1.getncattr(attrn) 8930 newattr = objofile.setncattr(attrn, attrval) 8931 8932 add_global_PyNCplot(objofile, 'nc_var_tools', fname, '2.0') 8933 newattr = objofile.setncattr('statisitcs', 'variables retrieved from ' +\ 8934 'files '+ file1 + ' & ' + file2) 8757 8935 else: 8758 dimsize = len(dimobj) 8759 8760 newdim = objofile.createDimension(dimn, dimsize) 8761 8762 # Variables 8763 fvars = objnc1.variables 8764 for varn in fvars: 8765 if varn != var1: 8766 varobj = objnc1.variables[varn] 8767 if varn != var1: 8768 newvar = objofile.createVariable(varn, varobj.dtype, \ 8769 varobj.dimensions) 8770 for attrn in varobj.ncattrs(): 8771 attrval = varobj.getncattr(attrn) 8772 newattr = newvar.setncattr(attrn, attrval) 8773 newvar[:] = varobj[:] 8774 8775 # Statistical variables 8776 vartype = objvar1.dtype 8777 varunits = objvar2.getncattr('units') 8778 8779 print 'vartype=',vartype 8780 8781 # temporal bias 8782 newvar = objofile.createVariable('t_bias_'+var1+'_'+var2, vartype, ('y', 'x'), \ 8783 fill_value = fillValue) 8784 newvar[:] = timecompare.bias 8785 newattr = basicvardef(newvar, 't_bias_'+var1+'_'+var2, 'temporal bias between ' +\ 8786 var1 + '&' + var2, varunits) 8787 8788 # temporal Standard deviation 8789 newvar = objofile.createVariable('t_stddev_'+var1+'_'+var2, vartype, ('y', 'x'), \ 8790 fill_value = fillValue) 8791 newvar[:] = timecompare.stdv1Sv2 8792 newattr = basicvardef(newvar, 't_stddev_'+var1+'_'+var2, \ 8793 'temporal standard deviation between '+ var1 + '&' + var2, varunits) 8794 8795 # space bias 8796 newvar = objofile.createVariable('s_bias_'+var1+'_'+var2, vartype, ('time'), \ 8797 fill_value = fillValue) 8798 newvar[:] = spacecompare.bias 8799 newattr = basicvardef(newvar, 's_bias_'+var1+'_'+var2, 'spatial bias between ' + \ 8800 var1 + '&' + var2, varunits) 8801 8802 # space Standard deviation 8803 newvar = objofile.createVariable('s_stddev_'+var1+'_'+var2, vartype, ('time'), \ 8804 fill_value = fillValue) 8805 newvar[:] = spacecompare.stdv1Sv2 8806 newattr = basicvardef(newvar, 's_stddev_'+var1+'_'+var2, \ 8807 'spatial standard deviation between '+ var1 + '&' + var2, varunits) 8808 8809 # t Correlation map 8810 newvar = objofile.createVariable('t_corr_'+var1+'_'+var2, vartype, ('y','x'), \ 8811 fill_value = fillValue) 8812 newvar[:] = timecompare.corr 8813 newattr = basicvardef(newvar, 't_corr_'+var1+'_'+var2, \ 8814 'temporal correlation between ' + var1 + '&' + var2, '-') 8815 newattr = newvar.setncattr('projection', 'lon lat') 8816 8817 # t p-value map 8818 newvar = objofile.createVariable('t_p_value_'+var1+'_'+var2, vartype, ('y','x'), \ 8819 fill_value = fillValue) 8820 newvar[:] = timecompare.p_value 8821 newattr = basicvardef(newvar, 't_p_value_'+var1+'_'+var2, \ 8822 'temporal p_value between ' + var1 + '&' + var2, '-') 8823 newattr = newvar.setncattr('projection', 'lon lat') 8824 8825 # s Correlation map 8826 newvar = objofile.createVariable('s_corr_'+var1+'_'+var2, vartype, ('time'), \ 8827 fill_value = fillValue) 8828 newvar[:] = spacecompare.corr 8829 newattr = basicvardef(newvar, 's_corr_'+var1+'_'+var2, \ 8830 'spatial correlation between ' + var1 + '&' + var2, '-') 8831 8832 # s p-value map 8833 newvar = objofile.createVariable('s_p_value_'+var1+'_'+var2, vartype, ('time'), \ 8834 fill_value = fillValue) 8835 newvar[:] = spacecompare.p_value 8836 newattr = basicvardef(newvar, 's_p_value_'+var1+'_'+var2, \ 8837 'spatial p_value between ' + var1 + '&' + var2, '-') 8838 8839 # print 'spatial means temporal correlation:',spacecompare.meancorr,'(', \ 8840 # (1.-spacecompare.meanp_value)*100.,' % significance)' 8841 8842 # t mean Correlation 8843 newvar = objofile.createVariable('t_mean_corr_'+var1+'_'+var2, 'f4') 8844 newvar[:] = timecompare.meancorr 8845 newattr = basicvardef(newvar, 't_mean_corr_'+var1+'_'+var2, \ 8846 'time mean values correlation between ' + var1 + '&' + var2, '-') 8847 8848 # t mean p-value 8849 newvar = objofile.createVariable('t_mean_p_value_'+var1+'_'+var2, 'f4') 8850 newvar[:] = timecompare.meanp_value 8851 newattr = basicvardef(newvar, 't_mean_p_value_'+var1+'_'+var2, \ 8852 'time mean p_value between ' + var1 + '&' + var2, '-') 8853 8854 # s mean Correlation 8855 newvar = objofile.createVariable('s_mean_corr_'+var1+'_'+var2, 'f4') 8856 newvar[:] = spacecompare.meancorr 8857 newattr = basicvardef(newvar, 's_mean_corr_'+var1+'_'+var2, \ 8858 'space mean values correlation between ' + var1 + '&' + var2, '-') 8859 8860 # s mean p-value 8861 newvar = objofile.createVariable('s_mean_p_value_'+var1+'_'+var2, 'f4') 8862 newvar[:] = spacecompare.meanp_value 8863 newattr = basicvardef(newvar, 's_mean_p_value_'+var1+'_'+var2, \ 8864 'space mean p_value between ' + var1 + '&' + var2, '-') 8865 8866 # Global attributes 8867 for attrn in objnc1.ncattrs(): 8868 attrval = objnc1.getncattr(attrn) 8869 newattr = objofile.setncattr(attrn, attrval) 8870 8871 newattr = objofile.setncattr('statisitcs', 'variables retrieved from files ' + \ 8872 file1 + ' & ' + file2) 8873 8936 if flavour == 'temporal' or flavour == 'both': 8937 print 'temporal bias between ' +var1+'&'+var2,':',timecompare.bias 8938 print 'temporal standard deviation ' +var1+'&'+var2,':', \ 8939 timecompare.stdv1Sv2 8940 print 'temporal correlation ' +var1+'&'+var2,':',timecompare.corr 8941 print 'temporal p_value ' +var1+'&'+var2,':',timecompare.p_value 8942 print 'temporal mean correlation ' +var1+'&'+var2,':', \ 8943 timecompare.meancorr 8944 print 'temporal mean p_value ' +var1+'&'+var2,':', \ 8945 timecompare.meanp_value 8946 8947 if flavour == 'spatial' or flavour == 'both': 8948 print 'spatial bias between ' +var1+'&'+var2,':',spacecompare.bias 8949 print 'spatial standard deviation ' +var1+'&'+var2,':', \ 8950 spacecompare.stdv1Sv2 8951 print 'spatial correlation ' +var1+'&'+var2,':',spacecompare.corr 8952 print 'spatial p_value ' +var1+'&'+var2,':',spacecompare.p_value 8953 print 'spatial mean correlation ' +var1+'&'+var2,':', \ 8954 spacecompare.meancorr 8955 print 'spatial mean p_value ' +var1+'&'+var2,':', \ 8956 spaceompare.meanp_value 8957 8874 8958 objnc1.close() 8875 8959 objnc2.close() 8876 8960 8877 objofile.sync() 8878 objofile.close() 8879 8880 varsfillvalue = ['t_bias_', 't_stddev_', 's_bias_', 's_stddev_', 't_corr_', \ 8881 't_p_value', 's_corr_', 's_p_value'] 8882 8883 # for varn in varsfillvalue: 8884 # print varn 8885 # fill = varaddattrk('_FillValue|'+ str(fillValue) + '|R32', ofile, \ 8886 # varn+var1+'_'+var2) 8887 8888 print ' ' + fname + ': successfull generation of file "' + ofile + '" !!!!!' 8961 if outfile: 8962 objofile.sync() 8963 objofile.close() 8964 8965 print ' ' + fname + ': successfull generation of file "' + ofile + '" !!' 8889 8966 8890 8967 return 8891 8968 8892 8969 #statcompare_files('control/sellonlatbox_wss_17-20.nc:wss,obs/re_project_Vu_17-20.nc:wss') 8970 #statcompare_files('diffstats,None,yes','/home/lluis/PY/wrfout_d01_1995-01-01_00:00:00,/home/lluis/PY/wrfout_d01_1995-01-01_00:00:00',\ 8971 # 'T2,U10,QVAPOR:T2,U10,QVAPOR') 8893 8972 8894 8973 def sellonlatlevbox(values, ncfile, varn):
Note: See TracChangeset
for help on using the changeset viewer.