8000 Improved support for coordinate epochs by attipaci · Pull Request #137 · Smithsonian/SuperNOVAS · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improved support for coordinate epochs #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ calculations.
- #135: New `novas_str_hours()` and `novas_str_degrees()` for the simplest conversion of strings in decimal or
HMS/DMS formats to floating point values for SuperNOVAS (without parse position).

- #137: New `novas_epoch()` to convert string coordinate system specifications to the Julian date of the corresponding
epoch, and new `make_cat_object_sys()` and `make_redshifted_object_sys()` to make it simpler to define ICRS catalog
sources in the coordinate system of choice.

- Added `example-time.c` and `example-rise-set.c` under `examples/`, for demonstrating date/time handling functions
and rise, set, and transit time calculations.

Expand Down
25 changes: 5 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,36 +472,21 @@ separators used between the components, e.g.:
And, if you have LSR-based radial velocities instead of Solar-system Barycentric radial velocities, you may convert
these to SSB-based velocities for use in `make_cat_entry()` with `novas_lsr_to_ssb_vel()`.

We must convert the older catalog coordinates to the now standard ICRS system for calculations in SuperNOVAS, first by
calculating equivalent J2000 coordinates, by applying the proper motion and the appropriate precession. Then, we apply
a small adjustment to convert from J2000 to ICRS coordinates.

```c
// First change the catalog coordinates (in place) to the J2000 (FK5) system...
transform_cat(CHANGE_EPOCH, NOVAS_JD_B1950, &star, NOVAS_JD_J2000, "FK5", &star);

// Then convert J2000 coordinates to ICRS (also in place). Here the dates don't matter...
transform_cat(CHANGE_J2000_TO_ICRS, 0.0, &star, 0.0, "ICRS", &star);
```

(Naturally, you can skip the transformation steps above if you have defined your source in ICRS coordinates from the
start.) Once the catalog entry is defined in ICRS, you can proceed wrapping it in a generic source structure (which
handles both catalog and Solar-system sources).

```c
object source; // Common structure for a sidereal or an Solar-system source

// Wrap it in a generic source data structure
make_cat_object(&star, &source);
// Wrap it in a generic source data structure, with ICRS coordinates...
make_cat_object_sys(&star, "B1950", &source);
```

Alternatively, for high-_z_ sources you might use `make_redshifted_cat_entry()` or `make_redshifted_object()` e.g.:
Alternatively, for high-_z_ sources you might use `make_redshifted_cat_entry()` or `make_redshifted_object_sys()`
e.g.:

```c
object quasar;

// 12h29m6.6997s +2d3m8.598s (ICRS) z=0.158339
make_redshifted_object("3c273", 12.4851944, 2.0523883, 0.158339, &quasar);
make_redshifted_object_sys("3c273", 12.4851944, 2.0523883, "ICRS", 0.158339, &quasar);
```

<a name="specify-observer"></a>
Expand Down
16 changes: 1 addition & 15 deletions examples/example-high-z.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,11 @@ int main() {
double ra0 = novas_str_hours("12h29m6.6997s");
double dec0 = novas_str_degrees("+2d3m8.598s");

if(make_redshifted_object("3c273", ra0, dec0, 0.158339, &source) != 0) {
if(make_redshifted_object_sys("3c273", ra0, dec0, "ICRS", 0.158339, &source) != 0) {
fprintf(stderr, "ERROR! defining cat_entry.\n");
return 1;
}

// If we did not use ICRS catalog coordinates, we would have to convert them to ICRS...

/* E.g. change B1950 to the J2000 (FK5) system...
if(transform_cat(CHANGE_EPOCH, NOVAS_JD_B1950, &source.star, NOVAS_JD_J2000, "FK5", &source.star) != 0) {
fprintf(stderr, "ERROR! converting B1950 catalog coordinates to J2000.\n");
return 1;
} */

/* Then convert J2000 coordinates to ICRS (also in place). Here the dates don't matter...
if(transform_cat(CHANGE_J2000_TO_ICRS, 0.0, &source.star, 0.0, "ICRS", &source.star) != 0) {
fprintf(stderr, "ERROR! converting J2000 catalog coordinates to ICRS.\n");
return 1;
} */


// -------------------------------------------------------------------------
// Define observer somewhere on Earth (we can also define observers in Earth
Expand Down
17 changes: 2 additions & 15 deletions examples/example-rise-set.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,9 @@ int main(int argc, const char *argv[]) {
return 1;
}

// First change the catalog coordinates (in place) to the J2000 (FK5) system...
if(transform_cat(CHANGE_EPOCH, NOVAS_JD_B1950, &star, NOVAS_JD_J2000, "FK5", &star) != 0) {
fprintf(stderr, "ERROR! converting B1950 catalog coordinates to J2000.\n");
return 1;
}

// Then convert J2000 coordinates to ICRS (also in place). Here the dates don't matter...
if(transform_cat(CHANGE_J2000_TO_ICRS, 0.0, &star, 0.0, "ICRS", &star) != 0) {
fprintf(stderr, "ERROR! converting J2000 catalog coordinates to ICRS.\n");
return 1;
}


// -------------------------------------------------------------------------
// Wrap the sidereal souce into an object structure...
if(make_cat_object(&star, &source) != 0) {
// Wrap the sidereal source into an object structure...
if(make_cat_object_sys(&star, "B1950", &source) != 0) {
fprintf(stderr, "ERROR! configuring observed object\n");
return 1;
}
Expand Down
18 changes: 3 additions & 15 deletions examples/example-star.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,16 @@ int main() {

// Convert string coordinates to hours/degrees...
double ra0 = novas_str_hours("16h26m20.1918s");
double dec0 = novas_str_degrees("-26d19m23.138s");
double dec0 = novas_str_degrees("-26d19m23.138s");

if(make_cat_entry("Antares", "FK4", 1, ra0, dec0, -12.11, -23.30, 5.89, -3.4, &star) != 0) {
fprintf(stderr, "ERROR! defining cat_entry.\n");
return 1;
}
// First change the catalog coordinates (in place) to the J2000 (FK5) system...
if(transform_cat(CHANGE_EPOCH, NOVAS_JD_B1950, &star, NOVAS_JD_J2000, "FK5", &star) != 0) {
fprintf(stderr, "ERROR! converting B1950 catalog coordinates to J2000.\n");
return 1;
}

// Then convert J2000 coordinates to ICRS (also in place). Here the dates don't matter...
if(transform_cat(CHANGE_J2000_TO_ICRS, 0.0, &star, 0.0, "ICRS", &star) != 0) {
fprintf(stderr, "ERROR! converting J2000 catalog coordinates to ICRS.\n");
return 1;
}


// -------------------------------------------------------------------------
// Wrap the sidereal souce into an object structure...
if(make_cat_object(&star, &source) != 0) {
// Wrap the sidereal source into an object structure with ICRS coordinates.
if(make_cat_object_sys(&star, "B1950", &source) != 0) {
fprintf(stderr, "ERROR! configuring observed object\n");
return 1;
}
Expand Down
33 changes: 32 additions & 1 deletion include/novas.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,30 @@
/// The day prior to that was 4 October 1582 in the Julian Calendar.
#define NOVAS_JD_START_GREGORIAN 2299160.5

/// The ICRS system as a string
/// @since 1.3
#define NOVAS_SYSTEM_ICRS "ICRS"

/// The B1950 coordiante system as a string
/// @since 1.3
#define NOVAS_SYSTEM_B1950 "B1950"

/// The J2000 coordinate syste, as a string
/// @since 1.3
#define NOVAS_SYSTEM_J2000 "J2000"

/// The 4th catalog (FK4) coordinate system as a string
/// @since 1.3
#define NOVAS_SYSTEM_FK4 "FK4"

/// The 5th catalog (FK5) coordinate system as a string
/// @since 1.3
#define NOVAS_SYSTEM_FK5 "FK5"

/// The Hipparcos dataset coordinate system as a string
/// @since 1.3
#define NOVAS_SYSTEM_HIP "HIP"

#if !COMPAT
// If we are not in the strict compatibility mode, where constants are defined
// as variables in novascon.h (with implementation in novascon.c), then define
Expand Down Expand Up @@ -1775,6 +1799,13 @@ int novas_xyz_to_los(const double *xyz, double lon, double lat, double *los);

int novas_xyz_to_uvw(const double *xyz, double ha, double dec, double *uvw);

int make_cat_object_sys(const cat_entry *star, const char *restrict system, object *source);

int make_redshifted_object_sys(const char *name, double ra, double dec, const char *restrict system, double z, object *source);

double novas_epoch(const char *restrict system);


// in parse.c
double novas_hms_hours(const char *restrict hms);

Expand Down Expand Up @@ -1836,7 +1867,6 @@ enum novas_timescale novas_parse_timescale(const char *restrict str, char **rest
int novas_print_timescale(enum novas_timescale scale, char *restrict buf);



// <================= END of SuperNOVAS API =====================>


Expand Down Expand Up @@ -1878,6 +1908,7 @@ int novas_print_timescale(enum novas_timescale scale, char *restrict buf);
# define DEG360 360.0
# define JULIAN_YEAR_DAYS 365.25
# define JULIAN_CENTURY_DAYS 36525.0
# define BESSELIAN_YEAR_DAYS 365.2568983
# define ARCSEC NOVAS_ARCSEC
# define DEGREE NOVAS_DEGREE
# define HOURANGLE NOVAS_HOURANGLE
Expand Down
4 changes: 3 additions & 1 deletion src/novas.c
Original file line number Diff line number Diff line change
Expand Up @@ -4544,6 +4544,7 @@ double rad_vel2(const object *restrict source, const double *pos_emit, const dou
*
* @sa nutation()
* @sa frame_tie()
* @sa novas_epoch()
* @sa tt2tdb()
* @sa cio_basis()
* @sa NOVAS_TOD
Expand Down Expand Up @@ -6318,6 +6319,7 @@ int novas_xyz_to_los(const double *xyz, double lon, double lat, double *los) {
*
* @sa transform_hip()
* @sa make_cat_entry()
* @sa novas_epoch()
* @sa NOVAS_JD_J2000
* @sa NOVAS_JD_B1950
* @sa NOVAS_JD_HIP
Expand Down Expand Up @@ -6967,7 +6969,7 @@ double norm_ang(double angle) {
*
* @sa novas_lsr_to_ssb_vel()
* @sa make_redshifted_cat_entry()
* @sa make_object()
* @sa make_cat_object_sys()
* @sa transform_cat()
*/
short make_cat_entry(const char *restrict star_name, const char *restrict catalog, long cat_num, double ra, double dec, double pm_ra, double pm_dec,
Expand Down
Loading
0