Skip to content

Commit

Permalink
Rebase master
Browse files Browse the repository at this point in the history
  • Loading branch information
dudewad committed Sep 10, 2024
1 parent ce6b096 commit 98de368
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 251 deletions.
9 changes: 4 additions & 5 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// #![allow(warnings)]
use clap::Parser;
use starfield_renderer::coords::{EquatorialCoords};
use starfield_renderer::fov::{get_fov};
use starfield_renderer::parsing_utils::{read_stars};
use starfield_renderer::rendering::{render_stars};
use starfinder::coords::{EquatorialCoords};
use starfinder::fov::{get_fov};
use starfinder::parsing_utils::{read_stars};
use starfinder::rendering::{render_stars};
use std::path::PathBuf;
use std::time::Instant;

Expand Down
2 changes: 1 addition & 1 deletion src/fov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn get_fov(
c_cartesian.z.powi(2) * (1.0 - roll.cos()) + roll.cos(),
);

let transform = z_roll * y_roll * x_roll;
let transform = x_roll * y_roll * z_roll;
let mut final_grid: HashSet<EquatorialCoords> = HashSet::new();
for p in scatter_shot {
let vec: Vector3<f64> = Vector3::new(p.x, p.y, p.z);
Expand Down
65 changes: 3 additions & 62 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
use clap::Parser;
use pyo3::prelude::*;

pub mod coords;
pub mod fov;
pub mod parsing_utils;
pub mod rendering;
pub mod star;

pub mod render;
pub mod star_catalog;
pub mod types;

use clap::Parser;
use pyo3::prelude::*;
use std::time::Instant;

use crate::render::render_stars;
use crate::star_catalog::read_stars;

#[pyclass]
#[derive(Parser, Debug, Clone)]
pub struct StarCatalogArgs {
Expand Down Expand Up @@ -70,57 +62,6 @@ impl StarCatalogArgs {
}
}

pub fn process_star_catalog(args: StarCatalogArgs) -> Result<(), Box<dyn std::error::Error>> {
println!("Reading stars from: {}", args.file);
println!("RA range: {} to {}", args.min_ra, args.max_ra);
println!("Dec range: {} to {}", args.min_dec, args.max_dec);
println!("Max magnitude: {}", args.max_magnitude);

let start = Instant::now();
let stars = read_stars(
&args.file,
args.min_ra,
args.max_ra,
args.min_dec,
args.max_dec,
args.max_magnitude,
)?;
let read_duration = start.elapsed();

println!("Time taken to read and filter stars: {:?}", read_duration);
println!("Total stars after filtering: {}", stars.len());

println!("\nFirst {} stars:", args.display_count);
for (i, star) in stars.iter().enumerate() {
if i >= args.display_count && args.display_count != 0 {
break;
}
println!(
"Star {}: RA={:.2}, Dec={:.2}, Mag={:.2}",
i, star.ra_deg, star.de_deg, star.mag
);
}

let render_start = Instant::now();
let img = render_stars(
&stars,
args.width,
args.height,
args.min_ra,
args.max_ra,
args.min_dec,
args.max_dec,
);
img.save(&args.output)?;
let render_duration = render_start.elapsed();

println!("Time taken to render and save image: {:?}", render_duration);
println!("Image saved as: {}", args.output);
println!("Total time elapsed: {:?}", start.elapsed());

Ok(())
}

#[pyfunction]
fn process_star_catalog_py(args: StarCatalogArgs) -> PyResult<()> {
process_star_catalog(args)
Expand Down
1 change: 0 additions & 1 deletion src/parsing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub enum CatalogError {
MissingMagnitude,
}


/// Reads and filters stars from the Tycho-2 catalog file.
/// https://heasarc.gsfc.nasa.gov/w3browse/all/tycho2.html
/// http://tdc-www.harvard.edu/catalogs/tycho2.format.html
Expand Down
41 changes: 0 additions & 41 deletions src/render.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn render_stars(
// Inverse the magnitude scale (brighter stars have lower magnitudes)
let normalized_mag = (max_mag - star.mag) / (max_mag - min_mag);
// Apply a non-linear scaling to emphasize brighter stars
let brightness = (normalized_mag.powf(2.5) * 255.0) as u8;
let brightness = (normalized_mag.powf(2.0) * 255.0) as u8;
let color = Rgb([brightness, brightness, brightness]);

img.put_pixel(x as u32, y as u32, color);
Expand Down
114 changes: 0 additions & 114 deletions src/star_catalog.rs

This file was deleted.

26 changes: 0 additions & 26 deletions src/types.rs

This file was deleted.

0 comments on commit 98de368

Please sign in to comment.