Skip to content
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

Automatically choose map data type #62

Open
ossama-othman opened this issue Dec 30, 2017 · 1 comment
Open

Automatically choose map data type #62

ossama-othman opened this issue Dec 30, 2017 · 1 comment
Assignees

Comments

@ossama-othman
Copy link
Owner

MaRC should automatically choose the map data type based on the data type in the source photo FITS file if a type is not explicitly chosen by the user. For example, if a source photo is comprised of 16 bit signed integers (FITS "short"), the generated map should also contain 16 bit signed integers.

@ossama-othman
Copy link
Owner Author

Map factory creation will likely need to be deferred to a point when source photo parameters are available, i..e. when the source photo FITS file has been opened. This will likely entail moving the map creation code out of the MaRC input file parser to a something like a new Abstract Factory (or other creational design pattern) implementation for MaRC's maps.

@ossama-othman ossama-othman added this to the v1.0 Release milestone Jan 12, 2018
@ossama-othman ossama-othman self-assigned this Aug 31, 2018
ossama-othman added a commit that referenced this issue Aug 31, 2018
Type-specific MapCommand instances are no longer created during MaRC
input file parsing.  Type-specific operations are now deferred until
the MapCommand is actually executed.  This allows type related
decisions to be made internally without user input.

Upcoming changes will include the automatic type selection logic.
Related to #62.
ossama-othman added a commit that referenced this issue Feb 1, 2019
* FITS_file: Begin encapsulating FITS file operations.

* lib: Corrected auto data scaling comments.

Clarified and corrected comments regarding calculation of scale and
offset values for MaRC virtual images.  The comments incorrectly
implied that no loss of significant digits would occur when assigning
the scaled and offset floating point values to an integer.  Some loss
of significant digits will always occur.  The goal is to retain as
many significant digits as possible without a complete loss of them.

* lib: Move scale_and_offset() to SourceImage.h.

Make the MaRC::scale_and_offset() function available to other MaRC
source images that aren't virtual images by moving it to the
SourceImage.h header.

* lib: Added sanity checks for cosine images.

* Clarify where physical data values are used.

* ImageFactory: Validate physical data min/max.

* src: Set appropriate min/max for virtual images.

Explicitly set narrower minimum and maximum values in MaRC virtual
image factories since we know what they are.

* src: Re-enable column retrieval in scanner.

* Removed need for MARC_HAS_3_PARAM_STD_HYPOT.

Since the 3 parameter version of std::hypot() is available in C++17,
simply check if the standard C++ __cplusplus preprocessor symbol is
defined to a value greater than or equal to 201703L, rather than
perform a check at configure-time.

This allows us to slightly reduce configure script maintenance and
size, as well as to avoid exposing the private <MaRC/config.h> header
through the public <MaRC/Mathematics.h> header.

* src: Address unused function warning.

* Address clang-specific warnings.

* src: Improved input file syntax error reporting.

* parse: Explicitly mark empty parser rules.

Per GNU Bison conventions, mark empty rules using the "%empty"
directive to make it obvious that the rule is indeed empty.

* parse: Eased requirements for MU and MU0 planes.

The MU plane no longer needs to have the sub-solar point specified.
It was never needed for emission angle calculations.  Similarly, the
MU0 plane no longer needs to have the sub-observer point and range
specified.  They were never needed for incidence angle computations.
No changes to the PHASE plane were made.  Fixes #59.

* lib: Add MaRC::optional<> implementation.

The new MaRC::optional<> class template implements a subset of the
standard C++17 std::optional<>.  It lacks conversion constructors, the
emplace() method, the std::hash() specialization, etc.  It exists to
allow MaRC to use std::optional<>-like functionality without forcing
it to require C++17 (std::optional<> was introduced in C++17).
However, if C++17 is enabled through compiler flags, the compiler
supplied std::optional<> will be used as the underlying
implementation.

MaRC::optional<> is only meant for use until MaRC's transition to
C++17 occurs.  As such, MaRC::optional<> is considered deprecated.  Do
not count on it to exist once MaRC requires C++17 (not expected any
time soon).

* lib: Fix problem of single longitude being mapped.

Corrected a problem where MaRC's Simple Cylindrical projection could
not handle the case where lower and upper longitudes in the map were
the same, signifying a 360 degree range. For example, passing 0 as the
lo_lon and hi_lon longitude values in the MaRC::SimpleCylindrical
constructor results in a map with a single longitude 0 being mapped
across all map pixels.  Fixes #95.

* src: Progress console implementation is now final.

MaRC::Progress::Console is not inherited any other class.  Declare it
as "final" to allow the compiler to perform additional optimizations.

* src: Silence unused argument warning.

* configure: Bump the version to 0.10a (alpha).

* Initialize map to provided blank value.

Initialize integer typed maps to the provided blank value, i.e.
DATA_BLANK in the MaRC input file, rather than zero.  This allows FITS
image readers to easily identify areas of integer typed maps that lack
data.  Fixes #94.

* Map_traits: No need to add 1 to min value.

* Map_traits: Simplify mininum()/maximum() traits.

Leverage std::min() and std::max() and a comment to make it obvious
what the code is doing.

Removed unnecessary 'float' specialization.

* lib: Determine map minimum and maximum only once.

* Map_traits: Minor Doxygen documentation updates.

* Moved to_unit_vector() and magnitude() to Vector.

It makes more sense for the MaRC::to_unit_vector() and
MaRC::magnitude() functions to be members of the MaRC::Vector<> class
template.  Changed accordingly.

* lib: Move scale_and_offset_impl() to details dir.

Move the MaRC::scale_and_offset<>() implementation details, i.e. the
related functors and specializations to the new `details' directory to
make it clear that they are not part of the public API.

* lib: Minor fixes to lat-lon-at-center code.

Fixed some issues with the viewing geometry code that compute rotation
matrices when the latitude and longitude at the center of the image
are given.  Vectors in different coordinate systems were be compared.
Relates to #29.

* lib: Make BodyData constructor constexpr.

* lib: Minor Doxygen documentation improvements.

* lib: Remove useless assignment operators.

Remove the assignment operators that accept an initializer list from
the MaRC::Vector and MaRC::Matrix class templates.  They are never
used since C++ copy-list-initialization (e.g. Vector foo = {1, 2, 3})
is performed through the constructor that accepts an initializer
list.

* Vector: Add parameter pack constructor.

Added a constexpr constructor to the MaRC::Vector<> class template
that accepts parameter pack.  This allows for direct initialization of
a Vector like so:

    MaRC::Vector<double, 3> foo(1, 2, 3);

and:

    constexpr MaRC::Vector<double, 3> foo(1, 2, 3);

The direct-list-initialization constructor, e.g. foo{1, 2, 3}, still
exists but it is not constexpr.

* ViewingGeometry: Directly initialize Vectors.

Simplify MaRC::Vector initialization by passing element values
directly to the constructor.

* Vector: Simplify ranged-based for loop in impl.

There was no need to use "*this" as the range expression in the
range-based for loop in the MaRC::Vector operator*=() and
to_unit_vector() implementation.  Just use the underlying fixed-size
array directly.

Added a note about why we don't do the same for the
MaRC::Matrix::operator*=().

* Vector_Test: Fix constexpr related build error.

Some older compilers don't allow a list-initialized
std::initializer_list<> to be declared constexpr since the
braced-initializer-list wasn't considered constexpr.

* tests: Add Vector and Matrix element access tests.

* MapFactory: Corrected blank value range check.

Verify that the user-supplied blank value, not the MaRC default blank
value, fits within the map data type.

* lib: Clarify need for floating point type in comp.

Clarify that the MaRC::almost_equal() and MaRC::almost_zero() function
templates require a floating point type by making the enabling
condition rely on std::is_floating_point<> rather than
!std::numeric_limits<>::is_integer.

* Removed redundant braces from initializer lists.

* Match include directives against install path.

Headers are installed in $prefix/include/marc not
$prefix/include/MaRC.  Adjust the include directives in the source
accordingly.  Fixes #97.

Added an installcheck-local rule that runs the installed `marc' binary
against the main MaRC test input file.  This change really belonged in
separate commit, but we'll let it slide this time.

* tests: Implemented tests for mu, mu0 and cos(phi).

Implemented oblate spheroid tests for the cosines of the emission,
incidence and and phase angles that calculate that confirm that
results of the MaRC::OblateSpheroid::{mu, mu0, cos_phase}() methods
return correct results, respectively.

* FITS_file: Support CFITSIO <= 3.39

Drop use of the fits_get_key_strlen() and fits_read_string_key()
functions that were introduced in CFITSIO 3.39 to support older
CFITSIO installations.

* src: Increase precision of stringified double.

* src: Removed MapCommand_T class template.

Type-specific MapCommand instances are no longer created during MaRC
input file parsing.  Type-specific operations are now deferred until
the MapCommand is actually executed.  This allows type related
decisions to be made internally without user input.

Upcoming changes will include the automatic type selection logic.
Related to #62.

* lib: Add include guards in template source.

* src: Work around old non-constexpr std::min().

Some older implementations of the std::min() function are not
constexpr despite the fact C++14 support is explicitly enabled.  Rely
on the ternary operator instead.

* Leverage C++14 attribute lists where applicable.

* lib: Remove deprecated MaRC::library_version().

* MapCommand: Make protected members private.

The MaRC::MapCommand class is no longer a base class, meaning there is
no need to make it some of its members protected to allow access by
subclasses.  Just mark those members as private.

* Support older Autoconf code coverage macros.

Work around the break in backward compatibility of the
AX_CODE_COVERAGE Autoconf Archive macro.  Both the old and new
versions of the macro are now supported.

* doc: Minor documentation clarification.

* Fixed code coverage build regression.

* README: Replace 'tarball' with 'tar archive'.

* README: Corrected header file installation path.

* m4: Reintroduced ax_code_coverage.m4 file.

Some very old autoconf-archive installation lack the
ax_code_coverage.m4 file.  Reintroduce the latest version.

* lib: Added note about grid interval validation.

* Mercator: Refactored redundant calculation.

* SimpleCylindrical: Make lat bounds const.

Initialize the Simple Cylindrical lower and upper map latitudes in a
way that allows their corresponding class members to be const.  This
should improve the potential for additional compiler based
optimizations.

* Revert "Mercator: Refactored redundant calculation."

This reverts commit 691b67565343af32235cd3c1359c95383c3df0bf.

Accuracy seems to drop slightly, causing the Mercator test to fail.
Revert for now.

* Replace use of spdlog with fmt library.

Source files that included <spdlog/spdlog.h> resulted in non-trival
increases in object file size.  Drop spdlog for now, and use the fmt
library (used by spdlog under the hood, too) to satisfy MaRC's simple
logging requirements, for now.  Fixes #96.

* MapFactory_t: Do not rely on NDEBUG definition.

There is no guarantee that the NDEBUG preprocessor symbol will be
defined in the MapFactory_t.cpp template source file since the private
<marc/config.h> header is not, and should not be, included.  Doing so
would expose that header to the user.  Removed code that relied on
that preprocessor symbol definition.

* MapFactory_t: Corrected blank value range check.

The check that attempted to verify that the user supplied map blank
value fit within the map data type range always succeeded since the
user supplied value was explicitly cast to the map data type before
the check.  Cast to the map data type after the check to allow the
test to fail when it should.

* tests: Improve MaRC test harness.

Leverage Automake's parallel test log compiler feature to simplify how
MaRC input files are tested.  MaRC input files now need only be listed
in the "TESTS" Makefile variable instead of creating a custom wrapper
script that runs MaRC on each input file.

* parse_scan: Simplify confusing error message.

* tests: Add negative tests.

Expanded the test suite by adding tests that are expected to fail due
to bad values in MaRC input files.  This exercises the error handling
in the MaRC input file parser.

* parse: Input file parser improvements.

Make "GRID" optional in input files (defaults to "NO"), and only allow
specification of the grid interval if the grid was enabled.

Added missing validation of ARCSEC_PER_PIX values.

Minor error message tweaks.

* Distribute 'opt' dir to fix distcheck.

* m4: Update autoconf archive macros.

* lib: Updated several constants.

Updated several physical constants and conversion factors to their
latest values, as revised by the BIPM and IAU.

* Improved static constants documentation.

* src: Clean up MaRC::FITS::traits class template.

Only specializations of the MaRC::FITS::traits<> class template are
ever expected to be used since there is no general way to define
traits for all CFITSIO image and type codes.  Only forward declare the
generalized class template to prevent potential errors related to
unhandled types from occurring in the future.

Drop the supports_blank_keyword trait in favor of a std::is_integral<>
based check.  There was no real need for that trait since it easy to
determine if the type in question is an integer at compile-time, and
thus support blank FITS values.

Corrected multiple Doxygen warnings and issues.

* lib: Added notes about physical constant updates.

* Fixed all Doxygen warnings.

* More Doxygen documentation corrections.

Prevent automatic linking to the MaRC and FITS namespaces where
appropriate, e.g. when referring to the MaRC program or library, and
the FITS standard.

Replaced incorrect usage of the Doxygen @internal special command with
@note.

* src: Begin consolidating map parameters.

Moved several map parameters found in the parser and the
MaRC::MapCommand class to a separate MapParameters class.  This allows
a single object to maintain map parameters instead of having
duplicates of those parameters in multiple locations.

Reduced number of global variables in the parser.

* lib: Move scale_and_offset() to its own header.

<marc/SourceImage.h> wasn't really the best place to put the
MaRC::scale_and_offset() function template.  Just place it in its own
header.

* Various doc corrections and improvements.

Corrected class and struct Doxygen documentation in the MaRC library
so that the header path includes the MaRC package include directory,
e.g. <marc/BodyData.h> instead of <BodyData.h>.

Minor Doxygen documentation corrections and improvements, including
file documentation that got mixed into macro documentation, and adding
template parameter documentation where appropriate.

* tests: Removed marc_program_test.sh

With the recent the changes to tests/Makefile.am that allowed MaRC
input files to be listed directly as tests there is no longer any need
for the marc_program_test.sh shell script.  Remove it.

* lib: Generalize image inversion functions.

Generalize the MaRC::invert_samples() and MaRC::invert_lines()
functions so that they work on any STL style container with the
appropriate iterators, as well as basic arrays.

* lib: Clarify map data values as "physical".

* src: Improved file parse error reporting.

Do not ignore syntax errors in the user configuration file.

Corrected typo that treated scanner initialization failure as a success.

* Read and set the unit in PhotoImages.

If available, read the unit name from the photo FITS file, and store
it in the PhotoImage for potential use in the map FITS file.

* lib: Minor documentation tweak.

* Leverage C++11 override where appropriate.

Use the C++11 "override" specifier on virtual functions that should
override a base class virtual function to help prevent inheritance
related errors (e.g. function overload vs override).

* src: Improve number parse error reporting.

Report underflow and overflow during conversion of stringified numbers
to a numerical value to the user.

Make division-by-zero error detection in the parser fatal.

* tests: Expand DATA_BLANK tests.

* Get fixed width integer types "std" namespace.

Since we're getting the fixed width integer types from the standard
C++ library <cstdint> header explicitly use the "std" namespace.

* Consolidate "blank_type" type alias declarations.

Use the "MaRC::plot_info::blank_type" alias in the MaRC library as the
underlying blank type used in the MaRC program.  This prevents
potential mismatches.

Replace the underlying blank integer type from int64_t to intmax_t in
case the platform supports an integer with greater than 64 bits.  The
blank integer value will still be cast as needed depending on the map
integer data type.

* lib: Fix ortho projection longitude validation.

* lib: Simplify Orthographic constructor.

* tests: Expand input file test.

* src: Fix BLANK value access.

The BLANK value should have the same type as the map projection.
Furthermore, use the address of the extracted blank value, not the
address of the MaRC::optional<> containing the blank value.

* tests: Minor Mercator test doc corrections.

* lib: Add constexpr OrthographicCenter constructor.

Added a constexpr MaRC::OrthographicCenter constructor to allow
constexpr instances to be declared.

* tests: Added new Orthographic projection test.

* Fix artifacts in the orthographic projection (#102)

* lib: Fixed MaRC::quadratic_roots() regression.

Fixed a regression in quadratic roots calculations that occurred when
the "b" coefficient of a quadratic equation being solved was zero.

This addresses problems that manifested in the Orthographic
projection, coordinate transformation calculations, etc.

* lib: Improve Orthographic projection precision.

Addressed a potential catastrophic cancellation in the Orthographic
projection in a calculation of the form (x*x - y*y).  Use the
equivalent form (x-y)(x+y) where cancellation due to subtraction is
benign.

* plot_info: Make construction more convenient.

MaRC::plot_info now has multiple constructors to handle three blank
value cases: (1) integer typed blank values, (2) floating point blank
values (these values are always ignored), and (3) no blank value
provided.  They were added to simplify construction of MaRC::plot_info
in generic code.

* tests: Orthographic projection test now passes.

The orthographic projection test was failing due to use of a map data
type that could not provide the precision necessary to support the
floating point equality strictness (small ulp value) in the test.
Force the use of either a floating point map data type, or an integer
type that is at least 64 bits wide.

* README.md: Update Travis CI URL.

* lib: Drop zero check in MaRC::quadratic_roots().

Drop the newly added "b == 0" check in MaRC::quadratic_roots() in
favor of a branchless implementation that relies on a newly added
MaRC::sgn() function.  The new MaRC::sgn() function returns the sign
of a real number.  It differs from the signum() function in that it
interprets the value zero as having a positive sign, i.e. 1, instead
of 0.  This behavior is required for the numerically stable form of
the quadratic formula implemented in MaRC::quadratic_roots().

* OblateSpheroid: Minor code simplification.

Simplify implementation of MaRC::OblateSpheroid::M() and
MaRC::OblateSpheroid::N() so that they are easier to read.

* src: Moved MaRC::strerror() to its own header.

* src: Move input file number conversion to parser.

Handle MaRC input file related string to number conversion in the
parser to make it possible to convert 64 bit integers in string form
directly to the underlying integer type instead of using variable of
type double as an intermediary.  Addresses an issue where the smallest
and largest 64 bit integers could be not be passed from the scanner to
the parser since the largest integer that can be stored in a 64 bit
IEEE 754 floating point value (type double) without loss of precision
is +/- 2^53.

* lib: Add missing include guards to <marc/Log.h>.

* plot_info: Disallow supplied NaN minimum/maximum.

* tests: Exercise 64 bit blank value.

* src: Defer setting source image extrema.

Postpone setting source image extrema until the image is created.
This addresses an issue that prevented 64 bit integer data from being
mapped.

* src: Fixed blank type mismatch when verifying.

Rather than type double, verify a blank value that has the same
integer type used by MaRC.  This allows 64 bit integer values to be
properly verified and formatted on error.

* parse: Renamed strtonum() to from_string().

* src: Mark BSCALE and BZERO as unset by default.

Do not set BSCALE and BZERO map parameters by default since we only
want to add them to the map FITS file if they were explicitly set.

* Minor doxygen documentation fixes.

* Matrix: Corrected typo documentation note.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant