PISM, A Parallel Ice Sheet Model  stable v2.0.6 committed by Constantine Khrulev on 2023-01-23 15:14:38 -0900
projection.hh
Go to the documentation of this file.
1 /* Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 PISM Authors
2  *
3  * This file is part of PISM.
4  *
5  * PISM is free software; you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation; either version 3 of the License, or (at your option) any later
8  * version.
9  *
10  * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with PISM; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef _PROJECTION_H_
21 #define _PROJECTION_H_
22 
23 #include <string>
24 
25 #include "Units.hh"
26 #include "VariableMetadata.hh"
27 
28 namespace pism {
29 
30 class File;
31 class IceModelVec2S;
32 class IceModelVec3;
33 
34 /*! @brief Convert a proj string with an EPSG code to a set of CF attributes. */
35 /*!
36  * Fails if `proj_string` does not contain an EPSG code.
37  */
38 VariableMetadata epsg_to_cf(units::System::Ptr system, const std::string &proj_string);
39 
40 class MappingInfo {
41 public:
42  MappingInfo(const std::string &mapping_name, units::System::Ptr unit_system);
44  std::string proj;
45 };
46 
47 /*! @brief Check consistency of the "mapping" variable with the EPSG code in the proj string. */
48 /*!
49  * If the consistency check fails, throws RuntimeError explaining the failure. Fails if `info.proj`
50  * does not use an EPSG code.
51  */
52 void check_consistency_epsg(const MappingInfo &info);
53 
54 /*! @brief Get projection info from a file. */
55 MappingInfo get_projection_info(const File &input_file, const std::string &mapping_name,
56  units::System::Ptr unit_system);
57 
58 void compute_longitude(const std::string &projection, IceModelVec2S &result);
59 void compute_latitude(const std::string &projection, IceModelVec2S &result);
60 
61 void compute_lon_bounds(const std::string &projection, IceModelVec3 &result);
62 void compute_lat_bounds(const std::string &projection, IceModelVec3 &result);
63 
64 } // end of namespace pism
65 
66 #endif /* _PROJECTION_H_ */
High-level PISM I/O class.
Definition: File.hh:51
A virtual class collecting methods common to ice and bedrock 3D fields.
Definition: iceModelVec.hh:404
std::string proj
Definition: projection.hh:44
VariableMetadata mapping
Definition: projection.hh:43
MappingInfo(const std::string &mapping_name, units::System::Ptr unit_system)
Definition: projection.cc:39
std::shared_ptr< System > Ptr
Definition: Units.hh:47
VariableMetadata epsg_to_cf(units::System::Ptr system, const std::string &proj_string)
Return CF-Convention "mapping" variable corresponding to an EPSG code specified in a PROJ string.
Definition: projection.cc:46
void check_consistency_epsg(const MappingInfo &info)
Check consistency of the "mapping" variable with the EPSG code in the proj string.
Definition: projection.cc:135
void compute_lon_bounds(const std::string &projection, IceModelVec3 &result)
Definition: projection.cc:425
void compute_latitude(const std::string &projection, IceModelVec2S &result)
Definition: projection.cc:421
MappingInfo get_projection_info(const File &input_file, const std::string &mapping_name, units::System::Ptr unit_system)
Get projection info from a file.
Definition: projection.cc:197
void compute_longitude(const std::string &projection, IceModelVec2S &result)
Definition: projection.cc:418
void compute_lat_bounds(const std::string &projection, IceModelVec3 &result)
Definition: projection.cc:429