Class: GlobalAttributes
- Inherits:
-
Object
- Object
- GlobalAttributes
- Defined in:
- lib/global_attributes.rb
Overview
required global netcdf attributes as described here: docs.google.com/document/d/1h0r8RZr_f3-8egBMMh7aqLwy3snpD6_MrDz1q8n5XUk/edit
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #as_hash ⇒ Object
- #days_in_year(year) ⇒ Object
- #frequency ⇒ Object
-
#initialize(version_date:, data_specs_version:, variable_info:, grid_info:, experiment_info:, parent_experiment_info: nil) ⇒ GlobalAttributes
constructor
A new instance of GlobalAttributes.
Constructor Details
#initialize(version_date:, data_specs_version:, variable_info:, grid_info:, experiment_info:, parent_experiment_info: nil) ⇒ GlobalAttributes
Returns a new instance of GlobalAttributes.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/global_attributes.rb', line 56 def initialize(version_date:, data_specs_version:, variable_info:, grid_info:, experiment_info:, parent_experiment_info:nil) institution_id = "AWI" mip_era = "CMIP6" sub_experiment_id = "none" indices_hash = indices_hash_from_variant_label(experiment_info.variant_label) @attributes = {} @attributes['activity_id'] = experiment_info.activity_id @attributes['Conventions'] = "CF-1.7 CMIP-6.2" # this depends on the version of the file https://docs.google.com/document/d/1h0r8RZr_f3-8egBMMh7aqLwy3snpD6_MrDz1q8n5XUk/edit @attributes['creation_date'] = "#{version_date.map{|x| sprintf('%02d',x)}.join('-')}T12:00:00Z" # we decided to use the same date as the date from the version directory (vYYYYMMDD), see section "Directory structure template" in https://docs.google.com/document/d/1h0r8RZr_f3-8egBMMh7aqLwy3snpD6_MrDz1q8n5XUk/edit @attributes['data_specs_version'] = data_specs_version @attributes['experiment'] = experiment_info.id @attributes['experiment_id'] = @attributes['experiment'] @attributes['forcing_index'] = indices_hash['forcing_index'] @attributes['frequency'] = variable_info.frequency @attributes['further_info_url'] = "https://furtherinfo.es-doc.org/#{mip_era}.#{institution_id}.#{experiment_info.source_id}.#{experiment_info.id}.#{sub_experiment_id}.#{experiment_info.variant_label}" @attributes['grid'] = grid_info.txt #cv['source_id'][experiment_info.source_id].model_component.ocean.description @attributes['grid_label'] = "gn" @attributes['initialization_index'] = indices_hash['initialization_index'] @attributes['institution'] = "Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research, Am Handelshafen 12, 27570 Bremerhaven, Germany" @attributes['institution_id'] = institution_id @attributes['license'] = "CMIP6 model data produced by Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research, Am Handelshafen 12, 27570 Bremerhaven, Germany is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (https://creativecommons.org/licenses/). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file). The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law." @attributes['mip_era'] = mip_era @attributes['nominal_resolution'] = grid_info.nominal_resolution @attributes['physics_index'] = indices_hash['physics_index'] @attributes['product'] = "model-output" @attributes['realization_index'] = indices_hash['realization_index'] @attributes['realm'] = variable_info.realms.join(' ') @attributes['source'] = experiment_info.source_id @attributes['source_id'] = @attributes['source'] @attributes['source_type'] = "AOGCM" @attributes['sub_experiment'] = "none" @attributes['sub_experiment_id'] = sub_experiment_id @attributes['table_id'] = variable_info.table_id @attributes['tracking_id'] = "hdl:21.14100/#{SecureRandom.uuid}" @attributes['variable_id'] = variable_info.id @attributes['variant_label'] = experiment_info.variant_label # @attributes['external_variables'] = #FESOM: areacello ECHAM: areacella # we do not reference any of these, so it is "not appropriate" to include this attribute if(parent_experiment_info) @attributes['branch_method'] = "standard" @attributes['branch_time_in_child'] = 0.0 d = 0; parent_experiment_info.first_year.upto(parent_experiment_info.branch_year-1) {|y| d += days_in_year y} @attributes['branch_time_in_parent'] = d.to_f @attributes['parent_activity_id'] = parent_experiment_info.activity_id @attributes['parent_experiment_id'] = parent_experiment_info.id @attributes['parent_mip_era'] = "CMIP6" @attributes['parent_source_id'] = parent_experiment_info.source_id @attributes['parent_time_units'] = "days since #{parent_experiment_info.first_year}-1-1" @attributes['parent_variant_label'] = parent_experiment_info.variant_label end @filename = create_filename(@attributes, experiment_info.first_year, experiment_info.last_year, variable_info.frequency) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
54 55 56 |
# File 'lib/global_attributes.rb', line 54 def filename @filename end |
Instance Method Details
#as_hash ⇒ Object
116 117 118 |
# File 'lib/global_attributes.rb', line 116 def as_hash @attributes end |
#days_in_year(year) ⇒ Object
138 139 140 |
# File 'lib/global_attributes.rb', line 138 def days_in_year(year) Date.new(year+1, 1, 1).next_day(-1).yday end |
#frequency ⇒ Object
111 112 113 |
# File 'lib/global_attributes.rb', line 111 def frequency @attributes['frequency'] end |