Created
January 31, 2014 19:43
-
-
Save smacfarlane/8741502 to your computer and use it in GitHub Desktop.
SIGRID Conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ice": { | |
"open_water_lookup_code": null, | |
"thick_ice_lookup_code": null, | |
"thin_ice_lookup_code": null, | |
"total_concentration": 4 | |
}, | |
"ice_observations": [ | |
{ | |
"biota_lookup_code": null, | |
"floe_size_lookup_code": null, | |
"ice_lookup_code": null, | |
"melt_pond": { | |
"freeboard": 15, | |
"max_depth_lookup_code": null, | |
"pattern_lookup_code": null, | |
"surface_coverage": 2, | |
"surface_lookup_code": null | |
}, | |
"obs_type": "primary", | |
"partial_concentration": 2, | |
"sediment_lookup_code": null, | |
"snow_lookup_code": null, | |
"snow_thickness": null, | |
"thickness": 100, | |
"topography": { | |
"concentration": 2, | |
"consolidated": "TRUE", | |
"old": true, | |
"ridge_height": 1, | |
"snow_covered": false, | |
"topography_lookup_code": null | |
} | |
}, | |
{ | |
"biota_lookup_code": null, | |
"floe_size_lookup_code": null, | |
"ice_lookup_code": null, | |
"melt_pond": { | |
"freeboard": null, | |
"max_depth_lookup_code": null, | |
"pattern_lookup_code": null, | |
"surface_coverage": 0, | |
"surface_lookup_code": null | |
}, | |
"obs_type": "secondary", | |
"partial_concentration": 2, | |
"sediment_lookup_code": null, | |
"snow_lookup_code": null, | |
"snow_thickness": null, | |
"thickness": 70, | |
"topography": { | |
"concentration": null, | |
"consolidated": null, | |
"old": null, | |
"ridge_height": null, | |
"snow_covered": null, | |
"topography_lookup_code": null | |
} | |
}, | |
{ | |
"biota_lookup_code": null, | |
"floe_size_lookup_code": null, | |
"ice_lookup_code": null, | |
"melt_pond": { | |
"freeboard": null, | |
"max_depth_lookup_code": null, | |
"pattern_lookup_code": null, | |
"surface_coverage": 0, | |
"surface_lookup_code": null | |
}, | |
"obs_type": "tertiary", | |
"partial_concentration": null, | |
"sediment_lookup_code": null, | |
"snow_lookup_code": null, | |
"snow_thickness": null, | |
"thickness": null, | |
"topography": { | |
"concentration": 4, | |
"consolidated": null, | |
"old": null, | |
"ridge_height": null, | |
"snow_covered": null, | |
"topography_lookup_code": null | |
} | |
} | |
], | |
"latitude": 71.6414, | |
"longitude": -151.0586, | |
"meteorology": { | |
"clouds": [ | |
{ | |
"cloud_lookup_code": null, | |
"cloud_type": "high", | |
"cover": null, | |
"height": null | |
}, | |
{ | |
"cloud_lookup_code": null, | |
"cloud_type": "medium", | |
"cover": null, | |
"height": null | |
}, | |
{ | |
"cloud_lookup_code": null, | |
"cloud_type": "low", | |
"cover": null, | |
"height": null | |
} | |
], | |
"visibility_lookup_code": null, | |
"weather_lookup_code": null | |
}, | |
"obs_datetime": "2012-08-08T21:08:00Z", | |
"primary_observer": { | |
"firstname": "Unknown", | |
"lastname": "Observer" | |
}, | |
"uuid": "02bbfd90-dd13-4b72-ae9d-096ab73c5314" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type":"Feature", | |
"geometry":{ | |
"type":"Point", | |
"coordinates":[-151.0586,71.6414] | |
}, | |
"properties":{ | |
"CT":"40", | |
"CTA":"20", | |
"CTB":"20", | |
"CTC":"55", | |
"DO":"1", | |
"WO":"1", | |
"SO":"1", | |
"PO":"1", | |
"RO":"1", | |
"EM":"85", | |
"SA":"80", | |
"SB":"80", | |
"SC":"80", | |
"CN":"80", | |
"CD":"80" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ice_concentration(assist_value) | |
case assist_value | |
when nil | |
'55' | |
when 0 | |
'01' | |
when 10 | |
'92' | |
else | |
(assist_value * 10).to_s | |
end | |
end | |
def ice_thickness(observation) | |
if observation.ice.total_concentration.nil? or observation.ice.total_concentration == 0 | |
0 | |
else | |
( | |
ice_percent_thickness(observation.ice_observations.primary) + | |
ice_percent_thickness(observation.ice_observations.secondary) + | |
ice_percent_thickness(observation.ice_observations.tertiary) | |
) / observation.ice.total_concentration | |
end | |
end | |
def water_coverage_area(observation) | |
if observation.ice.total_concentration.nil? or observation.ice.total_concentration == 0 | |
0 | |
else | |
( | |
melt_pond_percent_coverage(observation.ice_observations.primary) + | |
melt_pond_percent_coverage(observation.ice_observations.primary) + | |
melt_pond_percent_coverage(observation.ice_observations.primary) | |
) / observation.ice.total_concentration | |
end | |
end | |
def melt_pond_percent_coverage(ice_observation) | |
if ice_observation.partial_concentration.nil? or ice_observation.melt_pond.surface_coverage.nil? | |
0 | |
else | |
ice_observation.partial_concentration * ice_observation.melt_pond.surface_coverage | |
end | |
end | |
def ice_percent_thickness(ice_observation) | |
if ice_observation.partial_concentration.nil? | |
0 | |
else | |
ice_observation.partial_concentration * (ice_observation.thickness || 0) | |
end | |
end | |
def stage_of_development(ice_type_code, thickness) | |
case ice_type_code | |
when 10,11 | |
'81' | |
when 20 | |
'82' | |
when 30 | |
if thickness != nil and thickness >= 10 and thickness <= 30 | |
'84' | |
elsif thickness != nil and thickness > 30 and thickness <= 70 | |
'87' | |
else | |
'80' | |
end | |
when 40 | |
'84' | |
when 50 | |
'85' | |
when 60 | |
'87' | |
when 70 | |
'91' | |
when 80 | |
'93' | |
when 75 | |
'96' | |
when 85 | |
'97' | |
when 90 | |
'70' | |
when 95 | |
#TODO: I need a code here | |
'80' | |
else | |
'80' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment