-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05e4369
commit 57dc81f
Showing
3 changed files
with
81 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::io::Read; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum Precision { | ||
Single, | ||
Double, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Gather<T> { | ||
pub id: u16, | ||
pub nt: u16, | ||
pub nx: u16, | ||
pub dt: f32, | ||
pub data: Option<Vec<T>>, | ||
precision: Option<Precision>, | ||
} | ||
|
||
fn read_binary_file(file_name: &str) -> Vec<u8> { | ||
let mut file = std::fs::File::open(file_name).unwrap(); | ||
let mut buffer = Vec::new(); | ||
file.read_to_end(&mut buffer).unwrap(); | ||
buffer | ||
} | ||
|
||
fn load_data_into_gather<T>(path: &str, time_sampling: f32, samples_per_trace: u16, number_of_traces: u16 ) -> Gather<T> { | ||
let data_from_file = read_binary_file(path); | ||
Gather { | ||
id: 1, | ||
dt: time_sampling, | ||
nt: samples_per_trace, | ||
nx: number_of_traces, | ||
precision: None, | ||
data: None, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert_eq!(2, 2); | ||
} | ||
|
||
#[test] | ||
fn reads_binary_file() { | ||
let file_path: &str = "./resources/shot6220.bin"; | ||
let gather = load_data_into_gather(file_path, 0.004, 3101, 1000); | ||
println!("Gather: {:?}", gather) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1 @@ | ||
use std::io::Read; | ||
|
||
#[derive(Debug)] | ||
pub struct Gather { | ||
id: u16, | ||
nt: u16, | ||
nx: u16, | ||
dt: f32, | ||
data: Vec<u8>, | ||
} | ||
|
||
fn read_binary_file(file_name: &str) -> Vec<u8> { | ||
let mut file = std::fs::File::open(file_name).unwrap(); | ||
let mut buffer = Vec::new(); | ||
file.read_to_end(&mut buffer).unwrap(); | ||
buffer | ||
} | ||
|
||
fn load_data_into_gather(path: &str, time_sampling: f32, samples_per_trace: u16, number_of_traces: u16 ) -> Gather { | ||
Gather { | ||
id: 1, | ||
data: read_binary_file(path), | ||
dt: time_sampling, | ||
nt: samples_per_trace, | ||
nx: number_of_traces, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert_eq!(2, 2); | ||
} | ||
|
||
#[test] | ||
fn reads_binary_file() { | ||
let file_path: &str = "./resources/shot6220.bin"; | ||
let gather = load_data_into_gather(file_path, 0.004, 3101, 1000); | ||
println!("Gather: {:?}", gather) | ||
} | ||
} | ||
mod gather; |