Skip to content

Commit

Permalink
CMR-8370 Fixing the UMM-C migration to and from 1.17.0. If orbit par… (
Browse files Browse the repository at this point in the history
…#1593)

* CMR-8370 Fixing the UMM-C migration to and from 1.17.0.  If orbit parameters doesn't exist then don't change it.

* CMR-8370 improving code from PR
  • Loading branch information
eereiter authored and jwteague committed Jun 27, 2022
1 parent 86a4698 commit 1db8522
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
36 changes: 19 additions & 17 deletions umm-spec-lib/src/cmr/umm_spec/migration/version/collection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,18 @@
fields in 1.16.7. StartCircularLatitudeUnit is added only if StartCircularLatitude
exists."
[collection]
(let [orbit-period (get-in collection [:SpatialExtent :OrbitParameters :Period])
StartCircularLatitude (get-in collection [:SpatialExtent :OrbitParameters :StartCircularLatitude])
collection (-> collection
(update-in [:SpatialExtent :OrbitParameters] dissoc :Period)
(update-in [:SpatialExtent :OrbitParameters] assoc :SwathWidthUnit "Kilometer"
:OrbitPeriodUnit "Decimal Minute"
:InclinationAngleUnit "Degree"
:OrbitPeriod orbit-period))]
(if StartCircularLatitude
(assoc-in collection [:SpatialExtent :OrbitParameters :StartCircularLatitudeUnit] "Degree")
collection)))
(if-let [orbit-period (get-in collection [:SpatialExtent :OrbitParameters :Period])]
(let [StartCircularLatitude (get-in collection [:SpatialExtent :OrbitParameters :StartCircularLatitude])
collection (-> collection
(update-in [:SpatialExtent :OrbitParameters] dissoc :Period)
(update-in [:SpatialExtent :OrbitParameters] assoc :SwathWidthUnit "Kilometer"
:OrbitPeriodUnit "Decimal Minute"
:InclinationAngleUnit "Degree"
:OrbitPeriod orbit-period))]
(if StartCircularLatitude
(assoc-in collection [:SpatialExtent :OrbitParameters :StartCircularLatitudeUnit] "Degree")
collection))
collection))

(defn- get-largest-footprint-in-kilometer
"Convert all foot-prints to Kilometer, return the largest value."
Expand Down Expand Up @@ -166,12 +167,13 @@
convert SwathWidth to the value in assumed unit; If SwathWidth doesn't exist,
convert largest Footprint to SwathWidth."
[collection]
(let [swath-width (get-swath-width collection)
period (get-in collection [:SpatialExtent :OrbitParameters :OrbitPeriod])]
(-> collection
(update-in [:SpatialExtent :OrbitParameters] dissoc :Footprints :OrbitPeriod :SwathWidthUnit :OrbitPeriodUnit
:InclinationAngleUnit :StartCircularLatitudeUnit)
(update-in [:SpatialExtent :OrbitParameters] assoc :SwathWidth swath-width :Period period))))
(if-let [period (get-in collection [:SpatialExtent :OrbitParameters :OrbitPeriod])]
(let [swath-width (get-swath-width collection)]
(-> collection
(update-in [:SpatialExtent :OrbitParameters] dissoc :Footprints :OrbitPeriod :SwathWidthUnit :OrbitPeriodUnit
:InclinationAngleUnit :StartCircularLatitudeUnit)
(update-in [:SpatialExtent :OrbitParameters] assoc :SwathWidth swath-width :Period period)))
collection))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Collection Migration Implementations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3002,7 +3002,14 @@
:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/collection/v1.17.0",
:Name "UMM-C",
:Version "1.17.0"}}
{:SpatialExtent {:OrbitParameters OrbitParameters_1_16_7-2-Up}}))
{:SpatialExtent {:OrbitParameters OrbitParameters_1_16_7-2-Up}}

"Migrating up when Orbit Parameters is empty"
{:SpatialExtent {:OrbitParameters nil}
:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/collection/v1.17.0",
:Name "UMM-C",
:Version "1.17.0"}}
{:SpatialExtent {:OrbitParameters nil}}))

(deftest migrate-1-17-0-to-1-16-7
"Test the migration of collections from 1.17.0 to 1.16.7."
Expand All @@ -3029,6 +3036,13 @@
"Migrating with SwathWidth being the largest Footprint"
{:SpatialExtent {:OrbitParameters OrbitParameters_1_16_7-3-Down}}
{:SpatialExtent {:OrbitParameters OrbitParameters_1_17_0-3-Down}
:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/collection/v1.17.0",
:Name "UMM-C",
:Version "1.17.0"}}

"Migrating with no Orbit Paarameters"
{:SpatialExtent {:OrbitParameters nil}}
{:SpatialExtent {:OrbitParameters nil}
:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/collection/v1.17.0",
:Name "UMM-C",
:Version "1.17.0"}}))

0 comments on commit 1db8522

Please sign in to comment.