local globe = asset.require("../../earth")



local Name = "Phytoplankton Model"
local Identifier = "noaa-sos-oceans-phytoplankton"
local Description = [[Phytoplankton are the base of the marine food web and are crucial
players in the Earth's carbon cycle. They are also incredibly diverse. This visualization
shows dominant phytoplankton types from 1994-1998 generated by the Darwin Project using a
high-resolution ocean and ecosystem model. The model contains flow fields from 1994-1999
(generated by the ECCO2 model), inorganic nutrients, 78 species of phytoplankton,
zooplankton, as well as particulate and dissolved organic matter. Colors represent the
most dominant type of phytoplankton at a given location based on their size and ability
to uptake nutrients. Red represents diatoms (big phytoplankton, which need silica),
yellow represents flagellates (other big phytoplankton), green represents prochlorococcus
(small phytoplankton that cannot use nitrate), and cyan represents synechococcus (other
small phytoplankton). Opacity indicates concentration of the phytoplankton as carbon
biomass]]
local URL = "https://sos.noaa.gov/catalog/datasets/phytoplankton-model/"


local syncedDirectory = asset.syncedResource({
  Name = Name,
  Type = "HttpSynchronization",
  Identifier = Identifier,
  Version = 1,
  UnzipFiles = true,
  UnzipFilesDestination = "images"
})


local Layer = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ImageSequenceTileLayer",
  FolderPath = syncedDirectory .. "images",
  Description = Description
}

local Colorbar = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "colorbar.png",
  FaceCamera = false,
  CartesianPosition = { 0.8, 0.0, -2.0 }
}


asset.onInitialize(function()
  openspace.globebrowsing.addLayer(globe.Earth.Identifier, "ColorLayers", Layer)
  openspace.addScreenSpaceRenderable(Colorbar)
end)

asset.onDeinitialize(function()
  openspace.removeScreenSpaceRenderable(Colorbar)
  openspace.globebrowsing.deleteLayer(globe.Earth.Identifier, "ColorLayers", Layer)
end)

asset.export(Layer)
asset.export(Colorbar)



asset.meta = {
  Name = Name,
  Version = "1.0",
  Description = Description .. "Data provided by the National Oceanic and Atmospheric Administration",
  Author = "National Oceanic and Atmospheric Administration",
  URL = URL,
  License = "https://sos.noaa.gov/copyright/"
}
