This commit is contained in:
core 2023-11-14 07:15:53 -05:00
parent a2153d8219
commit c6f07ebf90
Signed by: core
GPG Key ID: FDBF740DADDCEECF
5 changed files with 97218 additions and 8 deletions

View File

@ -7,7 +7,7 @@ use std::fmt::{Display, Formatter};
use std::io; use std::io;
use std::io::{Cursor, Read, Seek, SeekFrom}; use std::io::{Cursor, Read, Seek, SeekFrom};
use std::str::Utf8Error; use std::str::Utf8Error;
use log::{info, trace, warn}; use log::{debug, info, trace, warn};
use crate::bzip::BzipDecoder; use crate::bzip::BzipDecoder;
use crate::message::{FromBody, LEGACY_CTM_HEADER_LEN, Message, MESSAGE_BODY_SIZE, MESSAGE_HEADER_SIZE, MessageHeader}; use crate::message::{FromBody, LEGACY_CTM_HEADER_LEN, Message, MESSAGE_BODY_SIZE, MESSAGE_HEADER_SIZE, MessageHeader};
use crate::message2::Msg02RDAStatusData; use crate::message2::Msg02RDAStatusData;
@ -109,7 +109,7 @@ pub fn parse_nx2_chunk(cursor: &mut (impl Read + Seek)) -> Result<Nexrad2Chunk,
if read != 24 { return Err(NexradParseError::InvalidHeaderLength(read)); } if read != 24 { return Err(NexradParseError::InvalidHeaderLength(read)); }
let tape_filename_bytes = &volume_header[0..9]; let tape_filename_bytes = &volume_header[0..9];
let tape_filename = std::str::from_utf8(tape_filename_bytes).map_err(|e| NexradParseError::InvalidHeaderTapeFilename(e))?; let tape_filename = std::str::from_utf8(tape_filename_bytes).map_err(NexradParseError::InvalidHeaderTapeFilename)?;
let extension_number_bytes = &volume_header[9..12]; let extension_number_bytes = &volume_header[9..12];
let extension_number = std::str::from_utf8(extension_number_bytes).map_err(|e| NexradParseError::InvalidHeaderTapeFilename(e))?; let extension_number = std::str::from_utf8(extension_number_bytes).map_err(|e| NexradParseError::InvalidHeaderTapeFilename(e))?;
@ -331,8 +331,12 @@ pub fn parse_nx2_chunk(cursor: &mut (impl Read + Seek)) -> Result<Nexrad2Chunk,
offset: f32::from_be_bytes(gdm_buf[24..28].try_into().unwrap()), offset: f32::from_be_bytes(gdm_buf[24..28].try_into().unwrap()),
}; };
debug!("gate count {} DWS {} mode {}", gdm.data_moment_gate_count, gdm.data_word_size, gdm.data_name);
let ldm = ((gdm.data_moment_gate_count as usize) * (gdm.data_word_size as usize))/8; let ldm = ((gdm.data_moment_gate_count as usize) * (gdm.data_word_size as usize))/8;
debug!("LDM length: {}", ldm);
let mut buf = vec![0u8; ldm]; let mut buf = vec![0u8; ldm];
decompressed.read_exact(&mut buf).map_err(|e| NexradParseError::Msg31MomentReadFailed(e))?; decompressed.read_exact(&mut buf).map_err(|e| NexradParseError::Msg31MomentReadFailed(e))?;

View File

@ -125,6 +125,8 @@ impl DataMoment {
pub fn scaled_data(&self) -> Vec<f32> { pub fn scaled_data(&self) -> Vec<f32> {
let mut gates = vec![0u16; self.gdm.data_moment_gate_count as usize]; let mut gates = vec![0u16; self.gdm.data_moment_gate_count as usize];
println!("data length: {}", self.data.len());
if self.gdm.data_word_size == 8 { if self.gdm.data_word_size == 8 {
for byte in &self.data { for byte in &self.data {
gates.push(*byte as u16); gates.push(*byte as u16);

96482
nxar2/log.txt Normal file

File diff suppressed because it is too large Load Diff

720
nxar2/log2.txt Normal file
View File

@ -0,0 +1,720 @@
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832
1832

View File

@ -22,9 +22,9 @@ impl NexradRenderExt for nexrad2::Nexrad2Chunk {
let moment_range = radials[0].available_data.get("REF").unwrap().gdm.data_moment_range; let moment_range = radials[0].available_data.get("REF").unwrap().gdm.data_moment_range;
let first_gate_px = moment_range as f32 / 1000.0 * px_per_km as f32; let first_gate_px = moment_range as f32 / 1000.0 * px_per_km as f32;
let gate_interval_km = radials[0].available_data.get("REF").unwrap().gdm.data_moment_range_sample_interval as f64 / 1000.0; let gate_interval_km = radials[0].available_data.get("REF").unwrap().gdm.data_moment_range_sample_interval as f64 / 1000.0;
println!("{}", gate_interval_km); //println!("{}", gate_interval_km);
let gate_width_px = gate_interval_km * px_per_km as f64; let gate_width_px = gate_interval_km * px_per_km as f64;
println!("{} {}", px_per_km, gate_width_px); //println!("{} {}", px_per_km, gate_width_px);
for radial in radials { for radial in radials {
let mut azimuth_angle = radial.header.azimuth_angle - 90.0; let mut azimuth_angle = radial.header.azimuth_angle - 90.0;
@ -40,11 +40,11 @@ impl NexradRenderExt for nexrad2::Nexrad2Chunk {
azimuth += azimuth_spacing; azimuth += azimuth_spacing;
} }
println!("azimuth: {}", azimuth); //println!("azimuth: {}", azimuth);
let start_angle = azimuth * (PI / 180.0); let start_angle = azimuth * (PI / 180.0);
println!("azimuth, radians: {}", start_angle); //println!("azimuth, radians: {}", start_angle);
let mut distance = first_gate_px; let mut distance = first_gate_px;
@ -52,6 +52,8 @@ impl NexradRenderExt for nexrad2::Nexrad2Chunk {
let gates = data_moment.scaled_data(); let gates = data_moment.scaled_data();
println!("{:?}", gates.len());
for gate in gates { for gate in gates {
if gate != MOMENT_DATA_BELOW_THRESHOLD { if gate != MOMENT_DATA_BELOW_THRESHOLD {
let mut pixel_x = (center as f32 + start_angle.cos() * distance).round() as usize; let mut pixel_x = (center as f32 + start_angle.cos() * distance).round() as usize;
@ -65,7 +67,7 @@ impl NexradRenderExt for nexrad2::Nexrad2Chunk {
} }
if pixel_y * image_size + pixel_x > (image_size * image_size) { if pixel_y * image_size + pixel_x > (image_size * image_size) {
println!("{} {}", pixel_x, pixel_y); //println!("{} {}", pixel_x, pixel_y);
} }
pixel_data[pixel_y * image_size + pixel_x] = color_scheme(product, gate); pixel_data[pixel_y * image_size + pixel_x] = color_scheme(product, gate);
@ -84,7 +86,7 @@ impl NexradRenderExt for nexrad2::Nexrad2Chunk {
} }
if pixel_y * image_size + pixel_x > (image_size * image_size) { if pixel_y * image_size + pixel_x > (image_size * image_size) {
println!("{} {}", pixel_x, pixel_y); //println!("{} {}", pixel_x, pixel_y);
} }
pixel_data[pixel_y * image_size + pixel_x] = [0.3, 0.2, 0.1]; pixel_data[pixel_y * image_size + pixel_x] = [0.3, 0.2, 0.1];