8 from pytmatrix.tmatrix
import tmatrix
17 print "Usage: read_obc_cal_data BAND START_DATE END_DATE OUTPUT_DRECTORY"
18 print "Example: read_obc_cal_data M6 20131130 20131202 /home/output_dir"
21 DaysInMonth = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
23 if (year == 2012
or year == 2016)
and month == 2:
26 return DaysInMonth[month]
30 str_day =
"0" +
str(day)
35 str_month =
"0" +
str(month)
37 str_month =
str(month)
39 str_date =
str(year) + str_month + str_day
44 if dataset_dtype.name ==
"int8":
45 extensible_atom = tables.Int8Atom()
46 if dataset_dtype.name ==
"uint8":
47 extensible_atom = tables.UInt8Atom()
48 elif dataset_dtype.name ==
"int16":
49 extensible_atom = tables.Int16Atom()
50 elif dataset_dtype.name ==
"uint16":
51 extensible_atom = tables.UInt16Atom()
52 elif dataset_dtype.name ==
"int32":
53 extensible_atom = tables.Int32Atom()
54 elif dataset_dtype.name ==
"uint32":
55 extensible_atom = tables.UInt32Atom()
56 elif dataset_dtype.name ==
"int64":
57 extensible_atom = tables.Int64Atom()
58 elif dataset_dtype.name ==
"uint64":
59 extensible_atom = tables.UInt64Atom()
60 elif dataset_dtype.name ==
"float32":
61 extensible_atom = tables.Float32Atom()
62 elif dataset_dtype.name ==
"float64":
63 extensible_atom = tables.Float64Atom()
65 return extensible_atom
67 """Tests for the T-matrix code.
69 Runs several tests that test the code. All tests should return ok.
70 If they don't, please contact the author.
72 suite = unittest.TestLoader().loadTestsFromTestCase(TMatrixTests)
73 unittest.TextTestRunner(verbosity=2).
run(suite)
80 Test basic table generation fortran code
83 (reff,veff,cext,csca,albedo,asym,f) = tmr.generate_tables()
85 print "\nEffective radius = " +
str(reff)
86 print "Effective volume = " +
str(veff)
87 print "Extinction Cross Section = " +
str(cext)
88 print "Scattering Cross Section = " +
str(csca)
89 print "Albedo = " +
str(albedo)
90 print "Asymmetry = " +
str(asym)
91 print "Scatter = " +
str(f)
95 Test basic table generation fortran code
98 (reff,veff,cext,csca,albedo,asym,f) = tmr.generate_tables()
101 str_out_dir =
"/accounts/ssander2/test/t_matrix_random"
102 out_filename =
"T-MATRIX_" + str_name +
".nc"
103 out_file_path = str_out_dir +
"/" + out_filename
106 ncfileout = tables.openFile(out_file_path,
"w",
"Scattering matrices")
108 print "-- ERROR! Invalid output filename entered --"
111 extensible_float32 = tables.Float32Atom()
120 tgroup = ncfileout.createGroup(
"/",
"test1",
'test')
122 effrad_list.append(ncfileout.createEArray(sv_group,
'Effective_Radius', extensible_float32, (0),
"Effective Radius"))
123 effrad_list.append(ncfileout.createEArray(sv_group,
'Effective Volume', extensible_float32, (0),
"Effective Volume"))
124 effrad_list.append(ncfileout.createEArray(sv_group,
'Extinction Cross Section', extensible_float32, (0),
"Extinction Cross Section"))
125 effrad_list.append(ncfileout.createEArray(sv_group,
'Scattering Cross Section', extensible_float32, (0),
"Scattering Cross Section"))
126 effrad_list.append(ncfileout.createEArray(sv_group,
'Asymmetry', extensible_float32, (0),
"Asymmetry"))
127 effrad_list.append(ncfileout.createEArray(sv_group,
'Scatter', extensible_float32, (0,tmr.angles,4,4),
"Scatter"))
131 if __name__ ==
'__main__':