1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! Setup module - handles application initialization.
//!
//! This module encapsulates all the setup steps needed before execution:
//! - Configuration resolution
//! - View transform calculation
//! - Data loading and processing
//!
//! This separation makes the initialization flow clear and testable.
use crateArgs;
use crateload_and_process_data;
use crateViewTransform;
/// Result of successful setup containing all initialized data.
/// Initialize the application configuration.
///
/// This function performs all necessary setup steps:
/// 1. Resolves plot configuration from CLI arguments
/// 2. Calculates view transformation (rotation)
/// 3. Loads and processes HEALPix data
///
/// # Arguments
///
/// * `args` - Parsed command-line arguments
/// * `verbose` - Whether to print progress messages
///
/// # Returns
///
/// A `SetupResult` containing initialized configuration and view transform,
/// or an error message describing what failed
///
/// # Errors
///
/// Returns an error if:
/// - Configuration resolution fails
/// - View transform calculation fails
/// - Data loading fails
/// - FITS file is invalid or unreadable
///
/// # Example
///
/// ```ignore
/// let setup = setup_initialization(&args, true)?;
/// // setup.config can now be used for plotting
/// // setup.view contains rotation information
/// ```
/// Load and process HEALPix data.
///
/// Handles loading FITS file data and applying any necessary preprocessing.
/// For gnomonic projections, uses a larger effective width to maintain resolution
/// when sampling a small field of view.
///
/// # Arguments
///
/// * `args` - Command-line arguments (contains FITS filename and column info)
/// * `verbose` - Whether to print progress messages
///
/// # Returns
///
/// Processed HEALPix data or an error message
///
/// # Errors
///
/// Returns an error if the FITS file cannot be read or processed
///
/// # Example
///
/// ```ignore
/// let data = load_data(&args, true)?;
/// println!("Loaded {} pixels", data.map.len());
/// ```