Skip to content

Commit

Permalink
Remove unused future imports from Python modules
Browse files Browse the repository at this point in the history
The `from __future__ import division` statement was removed across multiple
files, as it is no longer required in Python 3. This cleanup improves code
readability and aligns with modern Python standards.
  • Loading branch information
douglatornell committed Jan 8, 2025
1 parent 4ebc527 commit 4a75f0d
Show file tree
Hide file tree
Showing 36 changed files with 84 additions and 116 deletions.
1 change: 0 additions & 1 deletion I_ForcingFiles/Atmos/CheckAltitude.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"collapsed": false,
"input": [
"%matplotlib inline\n",
"from __future__ import division\n",
"import matplotlib.pyplot as plt\n",
"import netCDF4 as nc\n",
"import numpy as np\n",
Expand Down
1 change: 0 additions & 1 deletion I_ForcingFiles/Atmos/GetGrib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"collapsed": false,
"input": [
"# Standard Imports\n",
"from __future__ import division\n",
"import arrow\n",
"import os\n",
"import urllib"
Expand Down
2 changes: 0 additions & 2 deletions I_ForcingFiles/Atmos/InitialGEMCheck.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division, print_function\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import netCDF4 as nc\n",
"import numpy as np\n",
Expand Down
11 changes: 5 additions & 6 deletions I_ForcingFiles/Atmos/ProcessPramodArchive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"import arrow\n",
"import glob\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -475,7 +474,7 @@
" History: created by wgrib2\n",
" GRIB2_grid_template: 20\n",
" dimensions(sizes): y(266), x(256), time(62)\n",
" variables(dimensions): float64 \u001b[4my\u001b[0m(y), float64 \u001b[4mx\u001b[0m(x), float64 \u001b[4mlatitude\u001b[0m(y,x), float64 \u001b[4mlongitude\u001b[0m(y,x), float64 \u001b[4mtime\u001b[0m(time), float32 \u001b[4mDSWRF_surface\u001b[0m(time,y,x)\n",
" variables(dimensions): float64 \u001B[4my\u001B[0m(y), float64 \u001B[4mx\u001B[0m(x), float64 \u001B[4mlatitude\u001B[0m(y,x), float64 \u001B[4mlongitude\u001B[0m(y,x), float64 \u001B[4mtime\u001B[0m(time), float32 \u001B[4mDSWRF_surface\u001B[0m(time,y,x)\n",
" groups: \n",
"\n",
"<type 'netCDF4.Dataset'>\n",
Expand All @@ -484,7 +483,7 @@
" History: created by wgrib2\n",
" GRIB2_grid_template: 20\n",
" dimensions(sizes): y(266), x(256), time(62)\n",
" variables(dimensions): float64 \u001b[4my\u001b[0m(y), float64 \u001b[4mx\u001b[0m(x), float64 \u001b[4mlatitude\u001b[0m(y,x), float64 \u001b[4mlongitude\u001b[0m(y,x), float64 \u001b[4mtime\u001b[0m(time), float32 \u001b[4mDSWRF_surface\u001b[0m(time,y,x)\n",
" variables(dimensions): float64 \u001B[4my\u001B[0m(y), float64 \u001B[4mx\u001B[0m(x), float64 \u001B[4mlatitude\u001B[0m(y,x), float64 \u001B[4mlongitude\u001B[0m(y,x), float64 \u001B[4mtime\u001B[0m(time), float32 \u001B[4mDSWRF_surface\u001B[0m(time,y,x)\n",
" groups: \n"
]
},
Expand Down Expand Up @@ -703,9 +702,9 @@
"\n",
" # dataset attributes\n",
" nc_tools.init_dataset_attrs(\n",
" ncfile, \n",
" title='Atmos 2.5km Ops Forecast', \n",
" notebook_name='ProcessPramodArchive', \n",
" ncfile,\n",
" title='Atmos 2.5km Ops Forecast',\n",
" notebook_name='ProcessPramodArchive',\n",
" nc_filepath='/ocean/sallen/allen/research/MEOPAR/Operational/'+ncfilename,\n",
" comment='Dec processing',\n",
" )\n",
Expand Down
5 changes: 1 addition & 4 deletions I_ForcingFiles/Atmos/RadiationCheck.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"collapsed": false,
"input": [
"%matplotlib inline\n",
"from __future__ import division\n",
"import matplotlib.pyplot as plt\n",
"import netCDF4 as nc\n",
"import numpy as np\n",
Expand Down Expand Up @@ -704,9 +703,7 @@
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So Pramod's files do not begin at Dec 1, 2012 00:00. Check that ind matches with Kao Shen's time. "
]
"source": "So Pramod's files do not begin at Dec 1, 2012 00:00. Check that ind matches with Kao Shen's time."
},
{
"cell_type": "code",
Expand Down
1 change: 0 additions & 1 deletion I_ForcingFiles/Atmos/RebaseCGRF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"import cStringIO\n",
"import matplotlib.pyplot as plt\n",
"import requests\n",
Expand Down
15 changes: 7 additions & 8 deletions I_ForcingFiles/Atmos/VerifyAtmosphericForcing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"collapsed": false,
"input": [
"%matplotlib inline\n",
"from __future__ import division\n",
"import pprint\n",
"import matplotlib.pyplot as plt\n",
"import netCDF4 as nc\n",
Expand Down Expand Up @@ -442,7 +441,7 @@
"collapsed": false,
"input": [
"for p in cgrf_pts:\n",
" print (bathy.variables['nav_lat'][p['nearest_ji']], \n",
" print (bathy.variables['nav_lat'][p['nearest_ji']],\n",
" bathy.variables['nav_lon'][p['nearest_ji']])"
],
"language": "python",
Expand Down Expand Up @@ -667,7 +666,7 @@
"at the 1st time step implies that a non-uniform field of values\n",
"have been applied by NEMO.\n",
"\n",
"**Notes:** \n",
"**Notes:**\n",
"\n",
"* The run that produced these result was done before\n",
" removal of the degenerate bathymetry at the east end of Jervis Inlet\n",
Expand Down Expand Up @@ -841,9 +840,9 @@
"The values are close,\n",
"but nowhere near as close as expected.\n",
"Susan dug into the NEMO code and concluded that\n",
"the calculated wind components are subject to \n",
"atmospheric stability criteria manipulations \n",
"and are rescaled to be in a neutral atmosphere, \n",
"the calculated wind components are subject to\n",
"atmospheric stability criteria manipulations\n",
"and are rescaled to be in a neutral atmosphere,\n",
"so they do not directly reflect the applied forcing values."
]
},
Expand Down Expand Up @@ -944,7 +943,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It is evident that the expected wind component values \n",
"It is evident that the expected wind component values\n",
"from the CGRF files are being read by NEMO and interpolated\n",
"to the NEMO grid points."
]
Expand Down Expand Up @@ -1223,7 +1222,7 @@
"collapsed": false,
"input": [
"u_wind_1 = np.array((\n",
" -2.4427305818641006E-002, -2.3924413357676255E-002, -2.3421520896711501E-002, -2.2918628435746748E-002, \n",
" -2.4427305818641006E-002, -2.3924413357676255E-002, -2.3421520896711501E-002, -2.2918628435746748E-002,\n",
" -2.2415735974781997E-002, -2.1912843513817250E-002, -2.1409951052852497E-002, -2.0907058591887746E-002,\n",
" -2.0404166130922993E-002, -1.9901273669958246E-002))"
],
Expand Down
1 change: 0 additions & 1 deletion I_ForcingFiles/Atmos/correct_pressure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

# Call like this: python correct_pressure.py pressure_file temperature_file save_directory

from __future__ import division
import matplotlib.pyplot as plt
import netCDF4 as nc
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion I_ForcingFiles/Atmos/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""A collection of tools for comparing atmospheric forcing with
observations from the Salish Sea Model.
"""
from __future__ import division


import datetime
import netCDF4 as NC
Expand Down
17 changes: 8 additions & 9 deletions I_ForcingFiles/Initial/Create New TS file-bathymetry6&9.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"outputs": [],
"source": [
"from __future__ import division, print_function\n",
"from salishsea_tools import tidetools # for nearest point function\n",
"from salishsea_tools import nc_tools\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -301,7 +300,7 @@
"source": [
"## modify temperature for some grid cells\n",
"tempwanted = 5\n",
"k = 0 \n",
"k = 0\n",
"i = 413\n",
"j = 351\n",
"T[:, i, j:j+5] = tempwanted ## for(413, 351:355) from 0 to 4m\n",
Expand Down Expand Up @@ -409,9 +408,9 @@
"filename = '../../../NEMO-forcing/initial_strat/TS_01dec2002b.nc'\n",
"new_TS = nc.Dataset(filename, 'w')\n",
"nc_tools.init_dataset_attrs(\n",
" new_TS, \n",
" title='Salinity Temperature Initial Conditions based on spinup Dec 1 2002 for bathymetry6', \n",
" notebook_name='Create New TS file bathymetry6&9', \n",
" new_TS,\n",
" title='Salinity Temperature Initial Conditions based on spinup Dec 1 2002 for bathymetry6',\n",
" notebook_name='Create New TS file bathymetry6&9',\n",
" nc_filepath=filename,\n",
" comment='Salinity Temperature Initial Conditions based on spinup Dec 1 2002 for bathymetry6')\n",
"new_TS.createDimension('y', 898)\n",
Expand All @@ -436,17 +435,17 @@
"deptht = depths\n",
"time_counter = new_TS.createVariable('time_counter', 'float32', ('time_counter'))\n",
"time_counter.long_name = 'Time axis'\n",
"vosaline = new_TS.createVariable('vosaline', 'float32', \n",
"vosaline = new_TS.createVariable('vosaline', 'float32',\n",
" ('time_counter','deptht','y','x'))\n",
"vosaline.units = 'none'\n",
"vosaline.long_name = 'Practical Salinity' \n",
"vosaline.long_name = 'Practical Salinity'\n",
"vosaline.coordinates = 'nav_lon nav_lat deptht time_counter'\n",
"vosaline.grid = 'SalishSea6, north extended Fraser'\n",
"vosaline[0] = S\n",
"votemper = new_TS.createVariable('votemper', 'float32', \n",
"votemper = new_TS.createVariable('votemper', 'float32',\n",
" ('time_counter','deptht','y','x'))\n",
"votemper.units = 'degC'\n",
"votemper.long_name = 'Temperature' \n",
"votemper.long_name = 'Temperature'\n",
"votemper.coordinates = 'nav_lon nav_lat deptht time_counter'\n",
"votemper[0] = T\n",
"new_TS.history = \"\"\"[2015-12-05] Created\"\"\""
Expand Down
2 changes: 0 additions & 2 deletions I_ForcingFiles/OBC/Reading Neah Bay Surge website.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"\n",
"import netCDF4 as nc\n",
"import numpy as np\n",
"\n",
Expand Down
9 changes: 3 additions & 6 deletions I_ForcingFiles/Rivers/Rivers_2m.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notebook to create new river files at 2 m depth. "
]
"source": "Notebook to create new river files at 2 m depth."
},
{
"cell_type": "code",
Expand All @@ -23,7 +21,6 @@
"import netCDF4 as NC\n",
"import numpy as np\n",
"from salishsea_tools import nc_tools\n",
"from __future__ import division\n",
"import matplotlib.pylab as plt\n",
"\n",
"%matplotlib inline"
Expand Down Expand Up @@ -161,7 +158,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"#rivers_2m.variables['rodepth'][:] = \n",
"#rivers_2m.variables['rodepth'][:] =\n",
"rivers2m=NC.Dataset('rivers_2m_month.nc','r+')\n",
"rivers2m.description = 'Monthly Averages, All Rivers, depth 2m'\n",
"rivers2m.history = 'River files to 2 m depth'\n",
Expand Down Expand Up @@ -190,7 +187,7 @@
" description: Monthly Averages, All Rivers, depth 2m\n",
" history: River files to 2 m depth\n",
" dimensions(sizes): x(398), y(898), time_counter(12)\n",
" variables(dimensions): float32 \u001b[4mnav_lat\u001b[0m(y,x), float32 \u001b[4mnav_lon\u001b[0m(y,x), float32 \u001b[4mtime_counter\u001b[0m(time_counter), float32 \u001b[4mrorunoff\u001b[0m(time_counter,y,x), float32 \u001b[4mrodepth\u001b[0m(y,x)\n",
" variables(dimensions): float32 \u001B[4mnav_lat\u001B[0m(y,x), float32 \u001B[4mnav_lon\u001B[0m(y,x), float32 \u001B[4mtime_counter\u001B[0m(time_counter), float32 \u001B[4mrorunoff\u001B[0m(time_counter,y,x), float32 \u001B[4mrodepth\u001B[0m(y,x)\n",
" groups: \n",
"\n"
]
Expand Down
5 changes: 1 addition & 4 deletions SalishSeaTools/salishsea_tools/bathy_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
"""A library of Python functions for viewing and manipulating
netCDF bathymetry files.
"""
from __future__ import (
division,
print_function,
)


from matplotlib.colors import BoundaryNorm
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/nc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* combining per-processor sub-domain output files fron NEMO into a single
netCDF file
"""
from __future__ import division


from collections import namedtuple, OrderedDict
from datetime import datetime, timedelta
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/stormtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

"""A collection of tools for storm surge results from the Salish Sea Model.
"""
from __future__ import division


import csv
import datetime
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/teos_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
TEOS-10 is the Thermodynamic Equation of Seawater (2010).
See https://www.teos-10.org/.
"""
from __future__ import division


import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/tidetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""A collection of tools for dealing with tidal results from the
Salish Sea NEMO model
"""
from __future__ import division


import cmath
import collections
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/unit_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Salish Sea NEMO model unit conversion functions and constants.
"""
from __future__ import division


import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/viz_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""A collection of Python functions to do routine tasks associated with
plotting and visualization.
"""
from __future__ import division


import netCDF4 as nc
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/salishsea_tools/wind_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""Functions for working with wind model results and wind observations
data.
"""
from __future__ import division


from collections import namedtuple
from pathlib import Path
Expand Down
31 changes: 15 additions & 16 deletions SalishSeaTools/tests/test_bathy_tools.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
"""Unit tests for bathy_tools.
"""
# Copyright 2013 – present The Salish Sea MEOPAR contributors
# and The University of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import division

"""Unit tests for bathy_tools.
"""
Copyright 2013 – present The Salish Sea MEOPAR contributors
and The University of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import netCDF4 as nc
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/tests/test_nc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

"""Unit tests for nc_tools.
"""
from __future__ import division


import datetime
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion SalishSeaTools/tests/test_teos_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

"""Unit tests for the teos_tools module.
"""
from __future__ import division


import numpy as np
import pytest
Expand Down
Loading

0 comments on commit 4a75f0d

Please sign in to comment.