{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "66d8f25a-11aa-4c9c-b9ca-1caad69631f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import glob\n",
    "import numpy as np\n",
    "import xarray as xr\n",
    "import dask\n",
    "import pandas as pd\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "49f3c7a4-e435-4b83-904d-fc6b4b5604ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "#observations directory\n",
    "obsdir = '/global/cscratch1/sd/avarble/eagles/observations/ena/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "51a7b6c7-c9a0-4d2b-9760-9eae46c190a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "#set year to process\n",
    "stryear='2020'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8a703ea9-7d0a-4fcf-9409-3d4ae51aa167",
   "metadata": {},
   "outputs": [],
   "source": [
    "#ENA site latitude and longitude IDs\n",
    "#0.5-deg grid lat id = 7\n",
    "#0.5-deg grid lon id = 9\n",
    "#4-km pixel lat id = 195\n",
    "#4-km pixel lon id = 299\n",
    "#1-deg grid 1x1 lat id = 3, lon id = 4\n",
    "#1-deg grid 3x3 lat id = 2:5, lon id = 3:6"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83a63aac-6c77-4216-a5de-94c2de25ceb7",
   "metadata": {},
   "source": [
    "4-km VISST satellite retrieval files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "910cc74c-c4fc-47df-8611-30cef1172732",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Extract the ENA site from the 4-km pixel VISST satellite retrievals\n",
    "files = glob.glob(os.path.join(obsdir, 'visst/pix/enavisstpx2dm1*minnisX1.c1.'+stryear+'*.cdf'))\n",
    "files2 = sorted(files)\n",
    "\n",
    "data = xr.open_dataset(files2[0])\n",
    "base_time = data['base_time']\n",
    "time = data['time_offset']\n",
    "lat = data['latitude'][195,299]\n",
    "lon = data['longitude'][195,299]\n",
    "vis_reflectance = data['reflectance_vis'][195,299]\n",
    "wp = data['cloud_lwp_iwp'][195,299]\n",
    "phase = data['cloud_phase'][195,299] #0:snow, 1:water, 2:ice, 3:no retrievl, 4:clear, 5:bad data, 6:suspected water, 7:suspected ice, 13:cleaned data\n",
    "particle_size = data['cloud_particle_size'][195,299]\n",
    "cod = data['cloud_visible_optical_depth'][195,299]\n",
    "ctt = data['cloud_top_temperature'][195,299]\n",
    "ctp = data['cloud_top_pressure'][195,299]\n",
    "cth = data['cloud_top_height'][195,299]\n",
    "bb_lw = data['broadband_longwave_flux'][195,299]\n",
    "bb_sw_albedo = data['broadband_shortwave_albedo'][195,299]\n",
    "data.close()\n",
    "for file in files2[1:]:\n",
    "    data = xr.open_dataset(file)\n",
    "    time = xr.concat([time, data['time_offset']], dim=\"time\")\n",
    "    vis_reflectance = xr.concat([vis_reflectance, data['reflectance_vis'][195,299]], dim=\"time\")\n",
    "    wp = xr.concat([wp, data['cloud_lwp_iwp'][195,299]], dim=\"time\")\n",
    "    phase = xr.concat([phase, data['cloud_phase'][195,299]], dim=\"time\")\n",
    "    particle_size = xr.concat([particle_size, data['cloud_particle_size'][195,299]], dim=\"time\")\n",
    "    cod = xr.concat([cod, data['cloud_visible_optical_depth'][195,299]], dim=\"time\")\n",
    "    ctt = xr.concat([ctt, data['cloud_top_temperature'][195,299]], dim=\"time\")\n",
    "    ctp = xr.concat([ctp, data['cloud_top_pressure'][195,299]], dim=\"time\")\n",
    "    cth = xr.concat([cth, data['cloud_top_height'][195,299]], dim=\"time\")\n",
    "    bb_lw = xr.concat([bb_lw, data['broadband_longwave_flux'][195,299]], dim=\"time\")\n",
    "    bb_sw_albedo = xr.concat([bb_sw_albedo, data['broadband_shortwave_albedo'][195,299]], dim=\"time\")\n",
    "    data.close()\n",
    "\n",
    "#Cloud droplet number concentration retrieval files\n",
    "files = glob.glob(os.path.join(obsdir, 'visst/cdnc/pix/enavisstpx2dm1*minnisX1.cdnc.c1.'+stryear+'*.cdf'))\n",
    "files2 = sorted(files)\n",
    "\n",
    "data = xr.open_dataset(files2[0])\n",
    "cdnc = data['CDNC'][195,299]\n",
    "cdnc_ad = data['CDNC_adiabatic'][195,299]\n",
    "H = data['H'][195,299]\n",
    "H_ad = data['H_adiabatic'][195,299]\n",
    "data.close()\n",
    "for file in files2[1:]:\n",
    "    data = xr.open_dataset(file)\n",
    "    cdnc = xr.concat([cdnc, data['CDNC'][195,299]], dim=\"time\")\n",
    "    cdnc_ad = xr.concat([cdnc_ad, data['CDNC_adiabatic'][195,299]], dim=\"time\")\n",
    "    H = xr.concat([H, data['H'][195,299]], dim=\"time\")\n",
    "    H_ad = xr.concat([H_ad, data['H_adiabatic'][195,299]], dim=\"time\")\n",
    "    data.close()\n",
    "\n",
    "#write ENA site values to files for analyses\n",
    "ds = xr.Dataset({'base_time': ('time', np.arange(1)), 'base_time': base_time,\n",
    "                 'time_offset': ('time', time),\n",
    "                 'visible_reflectance': ('time', np.float32(vis_reflectance)),\n",
    "                 'broadband_longwave_flux': ('time', np.float32(bb_lw)),\n",
    "                 'broadband_shortwave_albedo': ('time', np.float32(bb_sw_albedo)),\n",
    "                 'cloud_top_temperature': ('time', np.float32(ctt)),\n",
    "                 'cloud_top_pressure': ('time', np.float32(ctp)),\n",
    "                 'cloud_top_height': ('time', np.float32(cth)),\n",
    "                 'cloud_optical_depth': ('time', np.float32(cod)),\n",
    "                 'cloud_particle_size': ('time', np.float32(particle_size)),\n",
    "                 'cloud_water_path': ('time', np.float32(wp)),\n",
    "                 'cloud_phase': ('time', np.float32(phase)),\n",
    "                 'cloud_drop_concentration': ('time', np.float32(cdnc)),\n",
    "                 'cloud_drop_concentration_adiabatic': ('time', np.float32(cdnc_ad)),\n",
    "                 'cloud_depth': ('time', np.float32(H)),\n",
    "                 'cloud_depth_adiabatic': ('time', np.float32(H_ad))},\n",
    "                 coords={'time': ('time', time)})\n",
    "\n",
    "#assign attributes\n",
    "ds['time'].attrs[\"long_name\"] = \"Time offset from midnight\"\n",
    "ds['time'].attrs[\"standard_name\"] = \"time\"\n",
    "ds['base_time'].attrs[\"ancillary_variables\"] = \"time_offset\"\n",
    "ds['time_offset'].attrs[\"long_name\"] = \"Time offset from base_time\"\n",
    "ds['time_offset'].attrs[\"ancillary_variables\"] = \"base_time\"\n",
    "ds['visible_reflectance'].attrs[\"long_name\"] = \"Visible Reflectance\"\n",
    "ds['visible_reflectance'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux'].attrs[\"long_name\"] = \"Broadband Longwave Radiation\"\n",
    "ds['broadband_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo'].attrs[\"long_name\"] = \"Broadband Shortwave Albedo\"\n",
    "ds['broadband_shortwave_albedo'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_temperature'].attrs[\"long_name\"] = \"Cloud Top Temperature\"\n",
    "ds['cloud_top_temperature'].attrs[\"units\"] = \"K\"\n",
    "ds['cloud_top_temperature'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_pressure'].attrs[\"long_name\"] = \"Cloud Top Pressure\"\n",
    "ds['cloud_top_pressure'].attrs[\"units\"] = \"hPa\"\n",
    "ds['cloud_top_pressure'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_height'].attrs[\"long_name\"] = \"Cloud Top Height\"\n",
    "ds['cloud_top_height'].attrs[\"units\"] = \"km\"\n",
    "ds['cloud_top_height'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_optical_depth'].attrs[\"long_name\"] = \"Cloud Optical Depth\"\n",
    "ds['cloud_optical_depth'].attrs[\"units\"] = \" \"\n",
    "ds['cloud_optical_depth'].attrs[\"description\"] = \"VISST retrieval.\"\n",
    "ds['cloud_particle_size'].attrs[\"long_name\"] = \"Cloud Top Effective Particle Size\"\n",
    "ds['cloud_particle_size'].attrs[\"units\"] = \"um\"\n",
    "ds['cloud_particle_size'].attrs[\"description\"] = \"VISST retrieval. Phase depends on Cloud Phase variable. If liquid, then this is radius. If ice, then diameter.\"\n",
    "ds['cloud_water_path'].attrs[\"long_name\"] = \"Cloud Water Path Average\"\n",
    "ds['cloud_water_path'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['cloud_water_path'].attrs[\"description\"] = \"VISST retrieval. Phase depends on Cloud Phase variable.\"\n",
    "ds['cloud_phase'].attrs[\"long_name\"] = \"Cloud Phase\"\n",
    "ds['cloud_phase'].attrs[\"units\"] = \" \"\n",
    "ds['cloud_phase'].attrs[\"description\"] = \"VISST retrieval. 0:snow, 1:water, 2:ice, 3:no retrievl, 4:clear, 5:bad data, 6:suspected water, 7:suspected ice, 13:cleaned data.\"\n",
    "ds['cloud_drop_concentration'].attrs[\"long_name\"] = \"Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 0.8.\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 1.\"\n",
    "ds['cloud_depth'].attrs[\"long_name\"] = \"Cloud Depth\"\n",
    "ds['cloud_depth'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 0.8.\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Depth\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 1.\"\n",
    "\n",
    "ds.attrs[\"description\"] = \"Cloud droplet concentration retrievals are only valid in overcast single layer liquid cloud situations with sufficiently high solar angles. The retrieval follows Bennartz with an adiabaticity of 0.8, except k is set to 0.74 rather than 0.8. The adiabatic retrievals assume adiabaticity = 1.\"\n",
    "ds.attrs[\"contact\"] = \"Adam Varble, adam.varble@pnnl.gov\"\n",
    "ds.attrs[\"date\"] = \"24 August 2021\"\n",
    "\n",
    "outfile = 'ENA_single_column_VISST_retrievals.pixel.'+stryear+'.nc'\n",
    "ds.to_netcdf(outfile, mode='w')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1c1b4c1-dfae-4fda-9857-f1a2f1b7ca8b",
   "metadata": {},
   "source": [
    "0.5-deg VISST satellite retrieval files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1410e6f7-5f64-44d4-aecb-6079da8fd2ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Extract the ENA site from the 0.5-deg VISST satellite retrievals\n",
    "files = glob.glob(os.path.join(obsdir, 'visst/grid/enavisstgridm11*minnisX1.c1.'+stryear+'*.cdf'))\n",
    "files2 = sorted(files)\n",
    "\n",
    "data = xr.open_dataset(files2[0])\n",
    "base_time = data['base_time']\n",
    "time = data['time']\n",
    "lat = data['latitude'][7]\n",
    "lon = data['longitude'][9]\n",
    "solar_zenith = data['solar_zenith_angle'][:,7,9]\n",
    "clearsky_vis_reflectance = data['clearsky_vis_reflectance'][:,7,9]\n",
    "vis_reflectance_all = data['visible_reflectance'][:,7,9,0]\n",
    "vis_reflectance_clr = data['visible_reflectance'][:,7,9,1]\n",
    "lwp = data['water_path'][:,7,9,1]\n",
    "iwp = data['water_path'][:,7,9,0]\n",
    "sfc_net_sw = data['surface_net_shortwave_flux'][:,7,9]\n",
    "sfc_net_lw = data['surface_net_longwave_flux'][:,7,9]\n",
    "sfc_down_sw = data['surface_down_shortwave_flux'][:,7,9]\n",
    "sfc_down_lw = data['surface_down_longwave_flux'][:,7,9]\n",
    "reff_liq = data['particle_size'][:,7,9,1]\n",
    "cod_liq_linavg = data['optical_depth_linear'][:,7,9,2]\n",
    "cod_liq_logavg = data['optical_depth_log'][:,7,9,2]\n",
    "ctt_liq = data['cloud_temperature'][:,7,9,2]\n",
    "ctp_liq = data['cloud_pressure_top'][:,7,9,2]\n",
    "cth_liq = data['cloud_height_top'][:,7,9,2]\n",
    "cf_all = data['cloud_percentage'][:,7,9,0]\n",
    "cf_liq = data['cloud_percentage'][:,7,9,2]\n",
    "bb_lw_all = data['broadband_longwave_flux'][:,7,9,0]\n",
    "bb_sw_albedo_all = data['broadband_shortwave_albedo'][:,7,9,0]\n",
    "bb_lw_clr = data['broadband_longwave_flux'][:,7,9,1]\n",
    "bb_sw_albedo_clr = data['broadband_shortwave_albedo'][:,7,9,1]\n",
    "data.close()\n",
    "for file in files2[1:]:\n",
    "    data = xr.open_dataset(file)\n",
    "    time = xr.concat([time, data['time']], dim=\"time\")\n",
    "    solar_zenith = xr.concat([solar_zenith, data['solar_zenith_angle'][:,7,9]], dim=\"time\")\n",
    "    clearsky_vis_reflectance = xr.concat([clearsky_vis_reflectance, data['clearsky_vis_reflectance'][:,7,9]], dim=\"time\")\n",
    "    vis_reflectance_all = xr.concat([vis_reflectance_all, data['visible_reflectance'][:,7,9,0]], dim=\"time\")\n",
    "    vis_reflectance_clr = xr.concat([vis_reflectance_clr, data['visible_reflectance'][:,7,9,1]], dim=\"time\")\n",
    "    lwp = xr.concat([lwp, data['water_path'][:,7,9,1]], dim=\"time\")\n",
    "    iwp = xr.concat([iwp, data['water_path'][:,7,9,0]], dim=\"time\")\n",
    "    sfc_net_sw = xr.concat([sfc_net_sw, data['surface_net_shortwave_flux'][:,7,9]], dim=\"time\")\n",
    "    sfc_net_lw = xr.concat([sfc_net_lw, data['surface_net_longwave_flux'][:,7,9]], dim=\"time\")\n",
    "    sfc_down_sw = xr.concat([sfc_down_sw, data['surface_down_shortwave_flux'][:,7,9]], dim=\"time\")\n",
    "    sfc_down_lw = xr.concat([sfc_down_lw, data['surface_down_longwave_flux'][:,7,9]], dim=\"time\")\n",
    "    reff_liq = xr.concat([reff_liq, data['particle_size'][:,7,9,1]], dim=\"time\")\n",
    "    cod_liq_linavg = xr.concat([cod_liq_linavg, data['optical_depth_linear'][:,7,9,2]], dim=\"time\")\n",
    "    cod_liq_logavg = xr.concat([cod_liq_logavg, data['optical_depth_log'][:,7,9,2]], dim=\"time\")\n",
    "    ctt_liq = xr.concat([ctt_liq, data['cloud_temperature'][:,7,9,2]], dim=\"time\")\n",
    "    ctp_liq = xr.concat([ctp_liq, data['cloud_pressure_top'][:,7,9,2]], dim=\"time\")\n",
    "    cth_liq = xr.concat([cth_liq, data['cloud_height_top'][:,7,9,2]], dim=\"time\")\n",
    "    cf_all = xr.concat([cf_all, data['cloud_percentage'][:,7,9,0]], dim=\"time\")\n",
    "    cf_liq = xr.concat([cf_liq, data['cloud_percentage'][:,7,9,2]], dim=\"time\")\n",
    "    bb_lw_all = xr.concat([bb_lw_all, data['broadband_longwave_flux'][:,7,9,0]], dim=\"time\")\n",
    "    bb_lw_clr = xr.concat([bb_lw_clr, data['broadband_longwave_flux'][:,7,9,1]], dim=\"time\")\n",
    "    bb_sw_albedo_all = xr.concat([bb_sw_albedo_all, data['broadband_shortwave_albedo'][:,7,9,0]], dim=\"time\")\n",
    "    bb_sw_albedo_clr = xr.concat([bb_sw_albedo_clr, data['broadband_shortwave_albedo'][:,7,9,1]], dim=\"time\")\n",
    "    data.close()\n",
    "\n",
    "#cloud drop number concentration retrievals\n",
    "files = glob.glob(os.path.join(obsdir, 'visst/cdnc/grid/enavisstgridm11*minnisX1.cdnc.c1.'+stryear+'*.cdf'))\n",
    "files2 = sorted(files)\n",
    "\n",
    "data = xr.open_dataset(files2[0])\n",
    "cdnc = data['CDNC'][:,7,9]\n",
    "cdnc_ad = data['CDNC_adiabatic'][:,7,9]\n",
    "H = data['H'][:,7,9]\n",
    "H_ad = data['H_adiabatic'][:,7,9]\n",
    "data.close()\n",
    "for file in files2[1:]:\n",
    "    data = xr.open_dataset(file)\n",
    "    cdnc = xr.concat([cdnc, data['CDNC'][:,7,9]], dim=\"time\")\n",
    "    cdnc_ad = xr.concat([cdnc_ad, data['CDNC_adiabatic'][:,7,9]], dim=\"time\")\n",
    "    H = xr.concat([H, data['H'][:,7,9]], dim=\"time\")\n",
    "    H_ad = xr.concat([ H_ad, data['H_adiabatic'][:,7,9]], dim=\"time\")\n",
    "    data.close()\n",
    "\n",
    "#write ENA site values to files for analyses\n",
    "ds = xr.Dataset({'base_time': ('time', np.arange(1)), 'base_time': base_time,\n",
    "                 'time_offset': ('time', time),\n",
    "                 'solar_zenith_angle': ('time', np.float32(solar_zenith)),\n",
    "                 'clearsky_vis_reflectance': ('time', np.float32(clearsky_vis_reflectance)),\n",
    "                 'visible_reflectance_all': ('time', np.float32(vis_reflectance_all)),\n",
    "                 'visible_reflectance_clear': ('time', np.float32(vis_reflectance_clr)),\n",
    "                 'broadband_longwave_flux_all': ('time', np.float32(bb_lw_all)),\n",
    "                 'broadband_longwave_flux_clear': ('time', np.float32(bb_lw_clr)),\n",
    "                 'broadband_shortwave_albedo_all': ('time', np.float32(bb_sw_albedo_all)),\n",
    "                 'broadband_shortwave_albedo_clear': ('time', np.float32(bb_sw_albedo_clr)),\n",
    "                 'surface_net_shortwave_flux': ('time', np.float32(sfc_net_sw)),\n",
    "                 'surface_net_longwave_flux': ('time', np.float32(sfc_net_lw)),\n",
    "                 'surface_down_shortwave_flux': ('time', np.float32(sfc_down_sw)),\n",
    "                 'surface_down_longwave_flux': ('time', np.float32(sfc_down_lw)),\n",
    "                 'cloud_percentage_all': ('time', np.float32(cf_all)),\n",
    "                 'cloud_percentage_liquid': ('time', np.float32(cf_liq)),\n",
    "                 'cloud_top_temperature_liquid': ('time', np.float32(ctt_liq)),\n",
    "                 'cloud_top_pressure_liquid': ('time', np.float32(ctp_liq)),\n",
    "                 'cloud_top_height_liquid': ('time', np.float32(cth_liq)),\n",
    "                 'optical_depth_linear_liquid': ('time', np.float32(cod_liq_linavg)),\n",
    "                 'optical_depth_log_liquid': ('time', np.float32(cod_liq_logavg)),\n",
    "                 'effective_radius_liquid': ('time', np.float32(reff_liq)),\n",
    "                 'water_path_liquid': ('time', np.float32(lwp)),\n",
    "                 'water_path_ice': ('time', np.float32(iwp)),\n",
    "                 'cloud_drop_concentration': ('time', np.float32(cdnc)),\n",
    "                 'cloud_drop_concentration_adiabatic': ('time', np.float32(cdnc_ad)),\n",
    "                 'cloud_depth': ('time', np.float32(H)),\n",
    "                 'cloud_depth_adiabatic': ('time', np.float32(H_ad))},\n",
    "                 coords={'time': ('time', time)})\n",
    "\n",
    "#assign attributes\n",
    "ds['time'].attrs[\"long_name\"] = \"Time offset from midnight\"\n",
    "ds['time'].attrs[\"standard_name\"] = \"time\"\n",
    "ds['base_time'].attrs[\"ancillary_variables\"] = \"time_offset\"\n",
    "ds['time_offset'].attrs[\"long_name\"] = \"Time offset from base_time\"\n",
    "ds['time_offset'].attrs[\"ancillary_variables\"] = \"base_time\"\n",
    "ds['solar_zenith_angle'].attrs[\"long_name\"] = \"Solar Zenith Angle\"\n",
    "ds['solar_zenith_angle'].attrs[\"units\"] = \"degrees\"\n",
    "ds['solar_zenith_angle'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"long_name\"] = \"Visible Clear Sky Reflectance Average\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"units\"] = \"fraction\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['visible_reflectance_all'].attrs[\"long_name\"] = \"All Sky Visible Reflectance Average \"\n",
    "ds['visible_reflectance_all'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['visible_reflectance_clear'].attrs[\"long_name\"] = \"Clear Sky Visible Reflectance Average\"\n",
    "ds['visible_reflectance_clear'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"long_name\"] = \"All Sky Upwelling Broadband Longwave Radiation Average\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"long_name\"] = \"Clear Sky Upwelling Broadband Longwave Radiation Average\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"long_name\"] = \"All Sky Upwelling Broadband Shortwave Albedo Average\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"long_name\"] = \"Clear Sky Upwelling Broadband Shortwave Albedo Average\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"long_name\"] = \"Surface Net Shortwave Flux Average\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"long_name\"] = \"Surface Net Longwave Flux Average\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"long_name\"] = \"Downward Shortwave Flux Average\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"long_name\"] = \"Downward Longwave Flux Average\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_percentage_all'].attrs[\"long_name\"] = \"All Sky Cloud Percentage\"\n",
    "ds['cloud_percentage_all'].attrs[\"units\"] = \"%\"\n",
    "ds['cloud_percentage_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"long_name\"] = \"Liquid Cloud Percentage\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"units\"] = \"%\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"long_name\"] = \"Cloud Top Temperature Average\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"units\"] = \"K\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"long_name\"] = \"Cloud Top Pressure Average\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"units\"] = \"hPa\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"long_name\"] = \"Cloud Top Height Average\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"units\"] = \"km\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"long_name\"] = \"Optical Depth Linear Average\"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"units\"] = \" \"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['optical_depth_log_liquid'].attrs[\"long_name\"] = \"Optical Depth Log Average\"\n",
    "ds['optical_depth_log_liquid'].attrs[\"units\"] = \" \"\n",
    "ds['optical_depth_log_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['effective_radius_liquid'].attrs[\"long_name\"] = \"Liquid Cloud Top Effective Radius Average\"\n",
    "ds['effective_radius_liquid'].attrs[\"units\"] = \"um\"\n",
    "ds['effective_radius_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['water_path_liquid'].attrs[\"long_name\"] = \"Liquid Water Path Average\"\n",
    "ds['water_path_liquid'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['water_path_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['water_path_ice'].attrs[\"long_name\"] = \"Ice Water Path Average\"\n",
    "ds['water_path_ice'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['water_path_ice'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_drop_concentration'].attrs[\"long_name\"] = \"Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 0.8.\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 1.\"\n",
    "ds['cloud_depth'].attrs[\"long_name\"] = \"Cloud Depth\"\n",
    "ds['cloud_depth'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 0.8.\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Depth\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 1.\"\n",
    "\n",
    "ds.attrs[\"description\"] = \"Cloud droplet concentration retrievals are only valid in overcast single layer liquid cloud situations with sufficiently high solar angles. The retrieval follows Bennartz with an adiabaticity of 0.8, except k is set to 0.74 rather than 0.8. The adiabatic retrievals assume adiabaticity = 1.\"\n",
    "ds.attrs[\"contact\"] = \"Adam Varble, adam.varble@pnnl.gov\"\n",
    "ds.attrs[\"date\"] = \"2 January 2021\"\n",
    "\n",
    "outfile = 'ENA_single_column_VISST_retrievals.grid.'+stryear+'.nc'\n",
    "ds.to_netcdf(outfile, mode='w')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e11da8df-f41f-4bb1-a56e-14ef9d400a90",
   "metadata": {},
   "source": [
    "1-deg VISST satellite retrieval files (only ENA site column)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4379acb6-2dd7-472f-84e1-b26863bd0890",
   "metadata": {},
   "outputs": [],
   "source": [
    "files = glob.glob(os.path.join(obsdir, 'visst/1deg/enavisstgridm1*minnisX1.c1.cdnc.1deg.'+stryear+'*.cdf'))\n",
    "files2 = sorted(files)\n",
    "\n",
    "data = xr.open_dataset(files2[0])\n",
    "base_time = data['base_time']\n",
    "time = data['time']\n",
    "lat = data['latitude'][3]\n",
    "lon = data['longitude'][4]\n",
    "solar_zenith = data['solar_zenith_angle'][:,3,4]\n",
    "clearsky_vis_reflectance = data['clearsky_visible_reflectance'][:,3,4]\n",
    "vis_reflectance_all = data['visible_reflectance'][:,3,4,0]\n",
    "vis_reflectance_clr = data['visible_reflectance'][:,3,4,1]\n",
    "lwp = data['water_path'][:,3,4,1]\n",
    "iwp = data['water_path'][:,3,4,0]\n",
    "sfc_net_sw = data['surface_net_shortwave_flux'][:,3,4]\n",
    "sfc_net_lw = data['surface_net_longwave_flux'][:,3,4]\n",
    "sfc_down_sw = data['surface_down_shortwave_flux'][:,3,4]\n",
    "sfc_down_lw = data['surface_down_longwave_flux'][:,3,4]\n",
    "reff_liq = data['particle_size'][:,3,4,1]\n",
    "cod_liq_linavg = data['optical_depth_linear'][:,3,4,2]\n",
    "cod_liq_logavg = data['optical_depth_log'][:,3,4,2]\n",
    "ctt_liq = data['cloud_temperature'][:,3,4,2]\n",
    "ctp_liq = data['cloud_pressure_top'][:,3,4,2]\n",
    "cth_liq = data['cloud_height_top'][:,3,4,2]\n",
    "cf_all = data['cloud_percentage'][:,3,4,0]\n",
    "cf_liq = data['cloud_percentage'][:,3,4,2]\n",
    "bb_lw_all = data['broadband_longwave_flux'][:,3,4,0]\n",
    "bb_sw_albedo_all = data['broadband_shortwave_albedo'][:,3,4,0]\n",
    "bb_lw_clr = data['broadband_longwave_flux'][:,3,4,1]\n",
    "bb_sw_albedo_clr = data['broadband_shortwave_albedo'][:,3,4,1]\n",
    "cdnc = data['CDNC'][:,3,4]\n",
    "cdnc_ad = data['CDNC_adiabatic'][:,3,4]\n",
    "H = data['H'][:,3,4]\n",
    "H_ad = data['H_adiabatic'][:,3,4]\n",
    "data.close()\n",
    "for file in files2[1:]:\n",
    "    data = xr.open_dataset(file)\n",
    "    time = xr.concat([time, data['time']], dim=\"time\")\n",
    "    solar_zenith = xr.concat([solar_zenith, data['solar_zenith_angle'][:,3,4]], dim=\"time\")\n",
    "    clearsky_vis_reflectance = xr.concat([clearsky_vis_reflectance, data['clearsky_visible_reflectance'][:,3,4]], dim=\"time\")\n",
    "    vis_reflectance_all = xr.concat([vis_reflectance_all, data['visible_reflectance'][:,3,4,0]], dim=\"time\")\n",
    "    vis_reflectance_clr = xr.concat([vis_reflectance_clr, data['visible_reflectance'][:,3,4,1]], dim=\"time\")\n",
    "    lwp = xr.concat([lwp, data['water_path'][:,3,4,1]], dim=\"time\")\n",
    "    iwp = xr.concat([iwp, data['water_path'][:,3,4,0]], dim=\"time\")\n",
    "    sfc_net_sw = xr.concat([sfc_net_sw, data['surface_net_shortwave_flux'][:,3,4]], dim=\"time\")\n",
    "    sfc_net_lw = xr.concat([sfc_net_lw, data['surface_net_longwave_flux'][:,3,4]], dim=\"time\")\n",
    "    sfc_down_sw = xr.concat([sfc_down_sw, data['surface_down_shortwave_flux'][:,3,4]], dim=\"time\")\n",
    "    sfc_down_lw = xr.concat([sfc_down_lw, data['surface_down_longwave_flux'][:,3,4]], dim=\"time\")\n",
    "    reff_liq = xr.concat([reff_liq, data['particle_size'][:,3,4,1]], dim=\"time\")\n",
    "    cod_liq_linavg = xr.concat([cod_liq_linavg, data['optical_depth_linear'][:,3,4,2]], dim=\"time\")\n",
    "    cod_liq_logavg = xr.concat([cod_liq_logavg, data['optical_depth_log'][:,3,4,2]], dim=\"time\")\n",
    "    ctt_liq = xr.concat([ctt_liq, data['cloud_temperature'][:,3,4,2]], dim=\"time\")\n",
    "    ctp_liq = xr.concat([ctp_liq, data['cloud_pressure_top'][:,3,4,2]], dim=\"time\")\n",
    "    cth_liq = xr.concat([cth_liq, data['cloud_height_top'][:,3,4,2]], dim=\"time\")\n",
    "    cf_all = xr.concat([cf_all, data['cloud_percentage'][:,3,4,0]], dim=\"time\")\n",
    "    cf_liq = xr.concat([cf_liq, data['cloud_percentage'][:,3,4,2]], dim=\"time\")\n",
    "    bb_lw_all = xr.concat([bb_lw_all, data['broadband_longwave_flux'][:,3,4,0]], dim=\"time\")\n",
    "    bb_lw_clr = xr.concat([bb_lw_clr, data['broadband_longwave_flux'][:,3,4,1]], dim=\"time\")\n",
    "    bb_sw_albedo_all = xr.concat([bb_sw_albedo_all, data['broadband_shortwave_albedo'][:,3,4,0]], dim=\"time\")\n",
    "    bb_sw_albedo_clr = xr.concat([bb_sw_albedo_clr, data['broadband_shortwave_albedo'][:,3,4,1]], dim=\"time\")\n",
    "    cdnc = xr.concat([cdnc, data['CDNC'][:,3,4]], dim=\"time\")\n",
    "    cdnc_ad = xr.concat([cdnc_ad, data['CDNC_adiabatic'][:,3,4]], dim=\"time\")\n",
    "    H = xr.concat([H, data['H'][:,3,4]], dim=\"time\")\n",
    "    H_ad = xr.concat([ H_ad, data['H_adiabatic'][:,3,4]], dim=\"time\")\n",
    "    data.close()\n",
    "\n",
    "#write ENA site values to files for analyses\n",
    "ds = xr.Dataset({'base_time': ('time', np.arange(1)), 'base_time': base_time,\n",
    "                 'time_offset': ('time', time),\n",
    "                 'solar_zenith_angle': ('time', np.float32(solar_zenith)),\n",
    "                 'clearsky_vis_reflectance': ('time', np.float32(clearsky_vis_reflectance)),\n",
    "                 'visible_reflectance_all': ('time', np.float32(vis_reflectance_all)),\n",
    "                 'visible_reflectance_clear': ('time', np.float32(vis_reflectance_clr)),\n",
    "                 'broadband_longwave_flux_all': ('time', np.float32(bb_lw_all)),\n",
    "                 'broadband_longwave_flux_clear': ('time', np.float32(bb_lw_clr)),\n",
    "                 'broadband_shortwave_albedo_all': ('time', np.float32(bb_sw_albedo_all)),\n",
    "                 'broadband_shortwave_albedo_clear': ('time', np.float32(bb_sw_albedo_clr)),\n",
    "                 'surface_net_shortwave_flux': ('time', np.float32(sfc_net_sw)),\n",
    "                 'surface_net_longwave_flux': ('time', np.float32(sfc_net_lw)),\n",
    "                 'surface_down_shortwave_flux': ('time', np.float32(sfc_down_sw)),\n",
    "                 'surface_down_longwave_flux': ('time', np.float32(sfc_down_lw)),\n",
    "                 'cloud_percentage_all': ('time', np.float32(cf_all)),\n",
    "                 'cloud_percentage_liquid': ('time', np.float32(cf_liq)),\n",
    "                 'cloud_top_temperature_liquid': ('time', np.float32(ctt_liq)),\n",
    "                 'cloud_top_pressure_liquid': ('time', np.float32(ctp_liq)),\n",
    "                 'cloud_top_height_liquid': ('time', np.float32(cth_liq)),\n",
    "                 'optical_depth_linear_liquid': ('time', np.float32(cod_liq_linavg)),\n",
    "                 'optical_depth_log_liquid': ('time', np.float32(cod_liq_logavg)),\n",
    "                 'effective_radius_liquid': ('time', np.float32(reff_liq)),\n",
    "                 'water_path_liquid': ('time', np.float32(lwp)),\n",
    "                 'water_path_ice': ('time', np.float32(iwp)),\n",
    "                 'cloud_drop_concentration': ('time', np.float32(cdnc)),\n",
    "                 'cloud_drop_concentration_adiabatic': ('time', np.float32(cdnc_ad)),\n",
    "                 'cloud_depth': ('time', np.float32(H)),\n",
    "                 'cloud_depth_adiabatic': ('time', np.float32(H_ad))},\n",
    "                 coords={'time': ('time', time)})\n",
    "\n",
    "#assign attributes\n",
    "ds['time'].attrs[\"long_name\"] = \"Time offset from midnight\"\n",
    "ds['time'].attrs[\"standard_name\"] = \"time\"\n",
    "ds['base_time'].attrs[\"ancillary_variables\"] = \"time_offset\"\n",
    "ds['time_offset'].attrs[\"long_name\"] = \"Time offset from base_time\"\n",
    "ds['time_offset'].attrs[\"ancillary_variables\"] = \"base_time\"\n",
    "ds['solar_zenith_angle'].attrs[\"long_name\"] = \"Solar Zenith Angle\"\n",
    "ds['solar_zenith_angle'].attrs[\"units\"] = \"degrees\"\n",
    "ds['solar_zenith_angle'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"long_name\"] = \"Visible Clear Sky Reflectance Average\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"units\"] = \"fraction\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['visible_reflectance_all'].attrs[\"long_name\"] = \"All Sky Visible Reflectance Average \"\n",
    "ds['visible_reflectance_all'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['visible_reflectance_clear'].attrs[\"long_name\"] = \"Clear Sky Visible Reflectance Average\"\n",
    "ds['visible_reflectance_clear'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"long_name\"] = \"All Sky Upwelling Broadband Longwave Radiation Average\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"long_name\"] = \"Clear Sky Upwelling Broadband Longwave Radiation Average\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"long_name\"] = \"All Sky Upwelling Broadband Shortwave Albedo Average\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"long_name\"] = \"Clear Sky Upwelling Broadband Shortwave Albedo Average\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"long_name\"] = \"Surface Net Shortwave Flux Average\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"long_name\"] = \"Surface Net Longwave Flux Average\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"long_name\"] = \"Downward Shortwave Flux Average\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"long_name\"] = \"Downward Longwave Flux Average\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_percentage_all'].attrs[\"long_name\"] = \"All Sky Cloud Percentage\"\n",
    "ds['cloud_percentage_all'].attrs[\"units\"] = \"%\"\n",
    "ds['cloud_percentage_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"long_name\"] = \"Liquid Cloud Percentage\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"units\"] = \"%\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"long_name\"] = \"Cloud Top Temperature Average\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"units\"] = \"K\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"long_name\"] = \"Cloud Top Pressure Average\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"units\"] = \"hPa\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"long_name\"] = \"Cloud Top Height Average\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"units\"] = \"km\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"long_name\"] = \"Optical Depth Linear Average\"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"units\"] = \" \"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['optical_depth_log_liquid'].attrs[\"long_name\"] = \"Optical Depth Log Average\"\n",
    "ds['optical_depth_log_liquid'].attrs[\"units\"] = \" \"\n",
    "ds['optical_depth_log_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['effective_radius_liquid'].attrs[\"long_name\"] = \"Liquid Cloud Top Effective Radius Average\"\n",
    "ds['effective_radius_liquid'].attrs[\"units\"] = \"um\"\n",
    "ds['effective_radius_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['water_path_liquid'].attrs[\"long_name\"] = \"Liquid Water Path Average\"\n",
    "ds['water_path_liquid'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['water_path_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['water_path_ice'].attrs[\"long_name\"] = \"Ice Water Path Average\"\n",
    "ds['water_path_ice'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['water_path_ice'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_drop_concentration'].attrs[\"long_name\"] = \"Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 0.8.\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 1.\"\n",
    "ds['cloud_depth'].attrs[\"long_name\"] = \"Cloud Depth\"\n",
    "ds['cloud_depth'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 0.8.\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Depth\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 1.\"\n",
    "\n",
    "ds.attrs[\"description\"] = \"These are 1-degree retrievals computed from the 0.5-degree VISST product. Cloud droplet concentration retrievals are only valid in overcast single layer liquid cloud situations with sufficiently high solar angles. The retrieval follows Bennartz with an adiabaticity of 0.8, except k is set to 0.74 rather than 0.8. The adiabatic retrievals assume adiabaticity = 1.\"\n",
    "ds.attrs[\"contact\"] = \"Adam Varble, adam.varble@pnnl.gov\"\n",
    "ds.attrs[\"date\"] = \"2 January 2021\"\n",
    "\n",
    "outfile = 'ENA_single_column_VISST_retrievals.grid.1deg.'+stryear+'.nc'\n",
    "ds.to_netcdf(outfile, mode='w')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dbceb691-289b-4e38-8fd0-a3b90ced8439",
   "metadata": {},
   "source": [
    "1-deg VISST satellite retrieval files (3 by 3 columns centered on ENA)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "2add9564-c238-4014-a18b-04f21773aeee",
   "metadata": {},
   "outputs": [],
   "source": [
    "files = glob.glob(os.path.join(obsdir, 'visst/1deg/enavisstgridm1*minnisX1.c1.cdnc.1deg.'+stryear+'*.cdf'))\n",
    "files2 = sorted(files)\n",
    "\n",
    "data = xr.open_dataset(files2[0])\n",
    "base_time = data['base_time']\n",
    "time = data['time']\n",
    "lat = data['latitude'][2:5]\n",
    "lon = data['longitude'][3:6]\n",
    "solar_zenith = data['solar_zenith_angle'][:,2:5,3:6]\n",
    "clearsky_vis_reflectance = data['clearsky_visible_reflectance'][:,2:5,3:6]\n",
    "vis_reflectance_all = data['visible_reflectance'][:,2:5,3:6,0]\n",
    "vis_reflectance_clr = data['visible_reflectance'][:,2:5,3:6,1]\n",
    "lwp = data['water_path'][:,2:5,3:6,1]\n",
    "iwp = data['water_path'][:,2:5,3:6,0]\n",
    "sfc_net_sw = data['surface_net_shortwave_flux'][:,2:5,3:6]\n",
    "sfc_net_lw = data['surface_net_longwave_flux'][:,2:5,3:6]\n",
    "sfc_down_sw = data['surface_down_shortwave_flux'][:,2:5,3:6]\n",
    "sfc_down_lw = data['surface_down_longwave_flux'][:,2:5,3:6]\n",
    "reff_liq = data['particle_size'][:,2:5,3:6,1]\n",
    "cod_liq_linavg = data['optical_depth_linear'][:,2:5,3:6,2]\n",
    "cod_liq_logavg = data['optical_depth_log'][:,2:5,3:6,2]\n",
    "ctt_liq = data['cloud_temperature'][:,2:5,3:6,2]\n",
    "ctp_liq = data['cloud_pressure_top'][:,2:5,3:6,2]\n",
    "cth_liq = data['cloud_height_top'][:,2:5,3:6,2]\n",
    "cf_all = data['cloud_percentage'][:,2:5,3:6,0]\n",
    "cf_liq = data['cloud_percentage'][:,2:5,3:6,2]\n",
    "bb_lw_all = data['broadband_longwave_flux'][:,2:5,3:6,0]\n",
    "bb_sw_albedo_all = data['broadband_shortwave_albedo'][:,2:5,3:6,0]\n",
    "bb_lw_clr = data['broadband_longwave_flux'][:,2:5,3:6,1]\n",
    "bb_sw_albedo_clr = data['broadband_shortwave_albedo'][:,2:5,3:6,1]\n",
    "cdnc = data['CDNC'][:,2:5,3:6]\n",
    "cdnc_ad = data['CDNC_adiabatic'][:,2:5,3:6]\n",
    "H = data['H'][:,2:5,3:6]\n",
    "H_ad = data['H_adiabatic'][:,2:5,3:6]\n",
    "data.close()\n",
    "for file in files2[1:]:\n",
    "    data = xr.open_dataset(file)\n",
    "    time = xr.concat([time, data['time']], dim=\"time\")\n",
    "    solar_zenith = xr.concat([solar_zenith, data['solar_zenith_angle'][:,2:5,3:6]], dim=\"time\")\n",
    "    clearsky_vis_reflectance = xr.concat([clearsky_vis_reflectance, data['clearsky_visible_reflectance'][:,2:5,3:6]], dim=\"time\")\n",
    "    vis_reflectance_all = xr.concat([vis_reflectance_all, data['visible_reflectance'][:,2:5,3:6,0]], dim=\"time\")\n",
    "    vis_reflectance_clr = xr.concat([vis_reflectance_clr, data['visible_reflectance'][:,2:5,3:6,1]], dim=\"time\")\n",
    "    lwp = xr.concat([lwp, data['water_path'][:,2:5,3:6,1]], dim=\"time\")\n",
    "    iwp = xr.concat([iwp, data['water_path'][:,2:5,3:6,0]], dim=\"time\")\n",
    "    sfc_net_sw = xr.concat([sfc_net_sw, data['surface_net_shortwave_flux'][:,2:5,3:6]], dim=\"time\")\n",
    "    sfc_net_lw = xr.concat([sfc_net_lw, data['surface_net_longwave_flux'][:,2:5,3:6]], dim=\"time\")\n",
    "    sfc_down_sw = xr.concat([sfc_down_sw, data['surface_down_shortwave_flux'][:,2:5,3:6]], dim=\"time\")\n",
    "    sfc_down_lw = xr.concat([sfc_down_lw, data['surface_down_longwave_flux'][:,2:5,3:6]], dim=\"time\")\n",
    "    reff_liq = xr.concat([reff_liq, data['particle_size'][:,2:5,3:6,1]], dim=\"time\")\n",
    "    cod_liq_linavg = xr.concat([cod_liq_linavg, data['optical_depth_linear'][:,2:5,3:6,2]], dim=\"time\")\n",
    "    cod_liq_logavg = xr.concat([cod_liq_logavg, data['optical_depth_log'][:,2:5,3:6,2]], dim=\"time\")\n",
    "    ctt_liq = xr.concat([ctt_liq, data['cloud_temperature'][:,2:5,3:6,2]], dim=\"time\")\n",
    "    ctp_liq = xr.concat([ctp_liq, data['cloud_pressure_top'][:,2:5,3:6,2]], dim=\"time\")\n",
    "    cth_liq = xr.concat([cth_liq, data['cloud_height_top'][:,2:5,3:6,2]], dim=\"time\")\n",
    "    cf_all = xr.concat([cf_all, data['cloud_percentage'][:,2:5,3:6,0]], dim=\"time\")\n",
    "    cf_liq = xr.concat([cf_liq, data['cloud_percentage'][:,2:5,3:6,2]], dim=\"time\")\n",
    "    bb_lw_all = xr.concat([bb_lw_all, data['broadband_longwave_flux'][:,2:5,3:6,0]], dim=\"time\")\n",
    "    bb_lw_clr = xr.concat([bb_lw_clr, data['broadband_longwave_flux'][:,2:5,3:6,1]], dim=\"time\")\n",
    "    bb_sw_albedo_all = xr.concat([bb_sw_albedo_all, data['broadband_shortwave_albedo'][:,2:5,3:6,0]], dim=\"time\")\n",
    "    bb_sw_albedo_clr = xr.concat([bb_sw_albedo_clr, data['broadband_shortwave_albedo'][:,2:5,3:6,1]], dim=\"time\")\n",
    "    cdnc = xr.concat([cdnc, data['CDNC'][:,2:5,3:6]], dim=\"time\")\n",
    "    cdnc_ad = xr.concat([cdnc_ad, data['CDNC_adiabatic'][:,2:5,3:6]], dim=\"time\")\n",
    "    H = xr.concat([H, data['H'][:,2:5,3:6]], dim=\"time\")\n",
    "    H_ad = xr.concat([ H_ad, data['H_adiabatic'][:,2:5,3:6]], dim=\"time\")\n",
    "    data.close()\n",
    "\n",
    "#write ENA site values to files for analyses\n",
    "ds = xr.Dataset({'base_time': ('time', np.arange(1)), 'base_time': base_time,\n",
    "                 'time_offset': ('time', time),\n",
    "                 'solar_zenith_angle': (('time','lat','lon'), np.float32(solar_zenith)),\n",
    "                 'clearsky_vis_reflectance': (('time','lat','lon'), np.float32(clearsky_vis_reflectance)),\n",
    "                 'visible_reflectance_all': (('time','lat','lon'), np.float32(vis_reflectance_all)),\n",
    "                 'visible_reflectance_clear': (('time','lat','lon'), np.float32(vis_reflectance_clr)),\n",
    "                 'broadband_longwave_flux_all': (('time','lat','lon'), np.float32(bb_lw_all)),\n",
    "                 'broadband_longwave_flux_clear': (('time','lat','lon'), np.float32(bb_lw_clr)),\n",
    "                 'broadband_shortwave_albedo_all': (('time','lat','lon'), np.float32(bb_sw_albedo_all)),\n",
    "                 'broadband_shortwave_albedo_clear': (('time','lat','lon'), np.float32(bb_sw_albedo_clr)),\n",
    "                 'surface_net_shortwave_flux': (('time','lat','lon'), np.float32(sfc_net_sw)),\n",
    "                 'surface_net_longwave_flux': (('time','lat','lon'), np.float32(sfc_net_lw)),\n",
    "                 'surface_down_shortwave_flux': (('time','lat','lon'), np.float32(sfc_down_sw)),\n",
    "                 'surface_down_longwave_flux': (('time','lat','lon'), np.float32(sfc_down_lw)),\n",
    "                 'cloud_percentage_all': (('time','lat','lon'), np.float32(cf_all)),\n",
    "                 'cloud_percentage_liquid': (('time','lat','lon'), np.float32(cf_liq)),\n",
    "                 'cloud_top_temperature_liquid': (('time','lat','lon'), np.float32(ctt_liq)),\n",
    "                 'cloud_top_pressure_liquid': (('time','lat','lon'), np.float32(ctp_liq)),\n",
    "                 'cloud_top_height_liquid': (('time','lat','lon'), np.float32(cth_liq)),\n",
    "                 'optical_depth_linear_liquid': (('time','lat','lon'), np.float32(cod_liq_linavg)),\n",
    "                 'optical_depth_log_liquid': (('time','lat','lon'), np.float32(cod_liq_logavg)),\n",
    "                 'effective_radius_liquid': (('time','lat','lon'), np.float32(reff_liq)),\n",
    "                 'water_path_liquid': (('time','lat','lon'), np.float32(lwp)),\n",
    "                 'water_path_ice': (('time','lat','lon'), np.float32(iwp)),\n",
    "                 'cloud_drop_concentration': (('time','lat','lon'), np.float32(cdnc)),\n",
    "                 'cloud_drop_concentration_adiabatic': (('time','lat','lon'), np.float32(cdnc_ad)),\n",
    "                 'cloud_depth': (('time','lat','lon'), np.float32(H)),\n",
    "                 'cloud_depth_adiabatic': (('time','lat','lon'), np.float32(H_ad))},\n",
    "                 coords={'time': ('time', time),\n",
    "                         'longitude': ('lon', lon),\n",
    "                         'latitude': ('lat', lat)})\n",
    "\n",
    "#assign attributes\n",
    "ds['time'].attrs[\"long_name\"] = \"Time offset from midnight\"\n",
    "ds['time'].attrs[\"standard_name\"] = \"time\"\n",
    "ds['base_time'].attrs[\"ancillary_variables\"] = \"time_offset\"\n",
    "ds['time_offset'].attrs[\"long_name\"] = \"Time offset from base_time\"\n",
    "ds['time_offset'].attrs[\"ancillary_variables\"] = \"base_time\"\n",
    "ds['solar_zenith_angle'].attrs[\"long_name\"] = \"Solar Zenith Angle\"\n",
    "ds['solar_zenith_angle'].attrs[\"units\"] = \"degrees\"\n",
    "ds['solar_zenith_angle'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"long_name\"] = \"Visible Clear Sky Reflectance Average\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"units\"] = \"fraction\"\n",
    "ds['clearsky_vis_reflectance'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['visible_reflectance_all'].attrs[\"long_name\"] = \"All Sky Visible Reflectance Average \"\n",
    "ds['visible_reflectance_all'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['visible_reflectance_clear'].attrs[\"long_name\"] = \"Clear Sky Visible Reflectance Average\"\n",
    "ds['visible_reflectance_clear'].attrs[\"units\"] = \"fraction\"\n",
    "ds['visible_reflectance_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"long_name\"] = \"All Sky Upwelling Broadband Longwave Radiation Average\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"long_name\"] = \"Clear Sky Upwelling Broadband Longwave Radiation Average\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['broadband_longwave_flux_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"long_name\"] = \"All Sky Upwelling Broadband Shortwave Albedo Average\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"long_name\"] = \"Clear Sky Upwelling Broadband Shortwave Albedo Average\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"units\"] = \"%\"\n",
    "ds['broadband_shortwave_albedo_clear'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"long_name\"] = \"Surface Net Shortwave Flux Average\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_net_shortwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"long_name\"] = \"Surface Net Longwave Flux Average\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_net_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"long_name\"] = \"Downward Shortwave Flux Average\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_down_shortwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"long_name\"] = \"Downward Longwave Flux Average\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"units\"] = \"W m-2\"\n",
    "ds['surface_down_longwave_flux'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_percentage_all'].attrs[\"long_name\"] = \"All Sky Cloud Percentage\"\n",
    "ds['cloud_percentage_all'].attrs[\"units\"] = \"%\"\n",
    "ds['cloud_percentage_all'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"long_name\"] = \"Liquid Cloud Percentage\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"units\"] = \"%\"\n",
    "ds['cloud_percentage_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"long_name\"] = \"Cloud Top Temperature Average\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"units\"] = \"K\"\n",
    "ds['cloud_top_temperature_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"long_name\"] = \"Cloud Top Pressure Average\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"units\"] = \"hPa\"\n",
    "ds['cloud_top_pressure_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"long_name\"] = \"Cloud Top Height Average\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"units\"] = \"km\"\n",
    "ds['cloud_top_height_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"long_name\"] = \"Optical Depth Linear Average\"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"units\"] = \" \"\n",
    "ds['optical_depth_linear_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['optical_depth_log_liquid'].attrs[\"long_name\"] = \"Optical Depth Log Average\"\n",
    "ds['optical_depth_log_liquid'].attrs[\"units\"] = \" \"\n",
    "ds['optical_depth_log_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['effective_radius_liquid'].attrs[\"long_name\"] = \"Liquid Cloud Top Effective Radius Average\"\n",
    "ds['effective_radius_liquid'].attrs[\"units\"] = \"um\"\n",
    "ds['effective_radius_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['water_path_liquid'].attrs[\"long_name\"] = \"Liquid Water Path Average\"\n",
    "ds['water_path_liquid'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['water_path_liquid'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['water_path_ice'].attrs[\"long_name\"] = \"Ice Water Path Average\"\n",
    "ds['water_path_ice'].attrs[\"units\"] = \"g m-2\"\n",
    "ds['water_path_ice'].attrs[\"description\"] = \"VISST retrieval\"\n",
    "ds['cloud_drop_concentration'].attrs[\"long_name\"] = \"Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 0.8.\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Droplet Concentration\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"units\"] = \" cm-3\"\n",
    "ds['cloud_drop_concentration_adiabatic'].attrs[\"description\"] = \"Retrieved following Bennartz using VISST product Meteosat data assuming adiabaticity = 1.\"\n",
    "ds['cloud_depth'].attrs[\"long_name\"] = \"Cloud Depth\"\n",
    "ds['cloud_depth'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 0.8.\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"long_name\"] = \"Adiabatic Cloud Depth\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"units\"] = \"m\"\n",
    "ds['cloud_depth_adiabatic'].attrs[\"description\"] = \"Estimated using satellite-retrieved LWP and moist adiabatic lapse rate with adiabaticity = 1.\"\n",
    "\n",
    "ds.attrs[\"description\"] = \"These are 1-degree retrievals computed from the 0.5-degree VISST product. Cloud droplet concentration retrievals are only valid in overcast single layer liquid cloud situations with sufficiently high solar angles. The retrieval follows Bennartz with an adiabaticity of 0.8, except k is set to 0.74 rather than 0.8. The adiabatic retrievals assume adiabaticity = 1.\"\n",
    "ds.attrs[\"contact\"] = \"Adam Varble, adam.varble@pnnl.gov\"\n",
    "ds.attrs[\"date\"] = \"2 January 2021\"\n",
    "\n",
    "outfile = 'ENA_3x3_VISST_retrievals.grid.1deg.'+stryear+'.nc'\n",
    "ds.to_netcdf(outfile, mode='w')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3f832756-f62f-48d4-b996-64d9801a61eb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "MyEnv",
   "language": "python",
   "name": "myenv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
