fixed pds parser

This commit is contained in:
sleptworld 2022-07-30 12:05:36 +08:00
parent a603af9869
commit 9b26b84f94
2 changed files with 21 additions and 20 deletions

View File

@ -185,13 +185,10 @@ fn levels(layer_indicator: u8, center: &PreConfParaTable, key_value: u16) -> Str
), ),
121 => format!("{}-{} mb", 1100 - o11, 1100 - o12), 121 => format!("{}-{} mb", 1100 - o11, 1100 - o12),
125 => format!("{} cm above gnd", key_value), 125 => format!("{} cm above gnd", key_value),
126 => { 126 => match center {
if let c = PreConfParaTable::NMC { PreConfParaTable::NMC => format!("{:.2} mb", key_value as f32 * 0.01),
format!("{:.2} mb", key_value as f32 * 0.01) _ => String::from("None"),
} else { },
String::from("None")
}
}
128 => format!( 128 => format!(
"{:.3}-{:.3} (sigma)", "{:.3}-{:.3} (sigma)",
1.1 - o11 as f32 / 1000.0, 1.1 - o11 as f32 / 1000.0,
@ -208,13 +205,10 @@ fn levels(layer_indicator: u8, center: &PreConfParaTable, key_value: u16) -> Str
207 => String::from("grid-scale cloud top"), 207 => String::from("grid-scale cloud top"),
209 => String::from("boundary layer cloud bottom"), 209 => String::from("boundary layer cloud bottom"),
210 => { 210 => match center {
if let c = PreConfParaTable::NMC { PreConfParaTable::NMC => String::from("boundary-layer cloud top"),
String::from("boundary-layer cloud top") _ => format!("{:.2} mb", key_value as f32 * 0.01),
} else { },
format!("{:.2} mb", key_value as f32 * 0.01)
}
}
211 => String::from("boundary layer cloud layer"), 211 => String::from("boundary layer cloud layer"),
212 => String::from("low cloud bottom"), 212 => String::from("low cloud bottom"),
@ -282,16 +276,21 @@ fn unit_parser(
sub_center: &SubCenter, sub_center: &SubCenter,
process: u8, process: u8,
) -> Parm { ) -> Parm {
let mut para_table: &'static [Parm; 256]; let mut para_table: &'static [Parm; 256] = &parm_tables::nceptable_opn::NCEP_OPN_PARM_TABLE;
match *center { match *center {
PreConfParaTable::NMC => { PreConfParaTable::NMC => {
if p_table <= 3 { if p_table <= 3 {
if let sub_center = SubCenter::NCEPReAnalysis { match sub_center {
para_table = &parm_tables::nceptable_reanal::NCEP_REANAL_PARM_TABLE; SubCenter::NCEPReAnalysis => {
para_table = &parm_tables::nceptable_reanal::NCEP_REANAL_PARM_TABLE
} }
if let sub_center = SubCenter::NWSMeteorologialDevLab {
para_table = &parm_tables::nceptable_mdl::NCEP_TABLE_MDL_PARM_TABLE; SubCenter::NWSMeteorologialDevLab => {
para_table = &parm_tables::nceptable_mdl::NCEP_TABLE_MDL_PARM_TABLE
}
_ => (),
} }
if (process != 80 && process != 180) || (p_table != 1 && p_table != 2) { if (process != 80 && process != 180) || (p_table != 1 && p_table != 2) {
@ -306,6 +305,7 @@ fn unit_parser(
133 => para_table = &parm_tables::nceptab_133::NCEP_133, 133 => para_table = &parm_tables::nceptab_133::NCEP_133,
140 => para_table = &parm_tables::nceptab_140::NCEP_140, 140 => para_table = &parm_tables::nceptab_140::NCEP_140,
141 => para_table = &parm_tables::nceptab_141::NCEP_141, 141 => para_table = &parm_tables::nceptab_141::NCEP_141,
_ => (),
} }
} }
} }

View File

@ -39,4 +39,5 @@ pub mod dwdtable_202;
pub mod dwdtable_203; pub mod dwdtable_203;
pub mod dwdtable_204; pub mod dwdtable_204;
pub mod dwdtable_205; pub mod dwdtable_205;
#[derive(Clone, Copy)]
pub struct Parm(&'static str, &'static str); pub struct Parm(&'static str, &'static str);