internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ARM-DOE/ACT

Issue:
act.utils.decode_present_weather classification tables
* ACT version: 1.4.2
* Python version: 3.9.16
* Operating System: Windows 10

### Description

I was working on decoding the FD70 present weather codes for the ATMOS FD70. It appears the FD70 uses both the WMO 4680 and 4677 in the numeric code. For it's metar code it uses WMO 4678. 

When the code encountered a value of 88, for snow pellets, which it adopted from the 4677 table, it errors and stops. Suggestion would possible be adding in some of the WMO4677 to fill number gaps if applicable. 

### What I Did

```
input: 
act.utils.decode_present_weather(ds,variable='present_wx0')
output:

  File D:\anaconda3\lib\site-packages\act\utils\inst_utils.py:133 in <listcomp>
    wx_type = [weather[d] for d in data.values]

KeyError: 88

```



Discussion:
@mtuftedal I can take a look at this and see what can be adjusted for it!
So I think the best way to approach this be to setup a separate lookup table, and do a join between the two.

For example, 88 is left as unknown in the 4677 standard, is defined in the 4678. When we do a join here, it will update those values without overriding the previous definitions.

Resolving patch:
diff --git a/act/utils/inst_utils.py b/act/utils/inst_utils.py
--- a/act/utils/inst_utils.py
+++ b/act/utils/inst_utils.py
@@ -6,8 +6,8 @@
 
 def decode_present_weather(ds, variable=None, decoded_name=None):
     """
-    This function is to decode codes reported from automatic weather stations suchas the PWD22.
-    This is based on WMO Table 4680.
+    This function is to decode codes reported from automatic weather stations such as the PWD22.
+    This is based on WMO Table 4680 as well as a supplement table for WMO table 4677.
 
     Parameters
     ----------
@@ -37,8 +37,8 @@ def decode_present_weather(ds, variable=None, decoded_name=None):
     if variable not in ds:
         raise ValueError('Variable not in the dataset')
 
-    # Define the weather hash
-    weather = {
+    # Define the weather hash for WMO table 4680.
+    weather_4680 = {
         0: 'No significant weather observed',
         1: 'Clouds generally dissolving or becoming less developed during the past hour',
         2: 'State of the sky on the whole unchanged during the past hour',
@@ -121,6 +121,18 @@ def decode_present_weather(ds, variable=None, decoded_name=None):
         -9999: 'Missing',
     }
 
+    # Define the weather hash for WMO table 4677.
+    weather_4677 = {
+        88: 'Shower(s) of snow pellets or small hail, with or without rain or rain and snow mixed, moderate or heavy',
+    }
+
+    # Join weather tables
+    weather_combined = dict(weather_4680)
+    weather_combined.update(weather_4677)
+
+    # Sort keys to be in order
+    weather = dict(sorted(weather_combined.items()))
+
     # If a decoded name is not passed, make one
     if decoded_name is None:
         decoded_name = variable + '_decoded'


Test patch:
Repository: ARM-DOE/ACT

Issue:
Feedstock failing due to pandas datetime
### Description
CI is failing due to datetime units not being set for csv reader

### What I Did

See the PR here that was failing
https://github.com/conda-forge/act-atmos-feedstock/pull/63



Discussion:

Resolving patch:
diff --git a/act/io/csvfiles.py b/act/io/csvfiles.py
--- a/act/io/csvfiles.py
+++ b/act/io/csvfiles.py
@@ -75,7 +75,7 @@ def read_csv(filename, sep=',', engine='python', column_names=None, skipfooter=0
 
     # Set Coordinates if there's a variable date_time
     if 'date_time' in df:
-        df.date_time = df.date_time.astype('datetime64')
+        df.date_time = df.date_time.astype('datetime64[ns]')
         df.time = df.date_time
         df = df.set_index('time')
 


Test patch:
Repository: ARM-DOE/ACT

Issue:
New Example Template
### Description

For new contributors that might want to contribute an example, it would be beneficial for them to have a template that they could use to get started.  Recommend that we add a "Template" section to the Examples area and include templates for Examples or even initial functions including documentation.


Discussion:

Resolving patch:
diff --git a/examples/templates/example_template.py b/examples/templates/example_template.py
new file mode 100644
--- /dev/null
+++ b/examples/templates/example_template.py
@@ -0,0 +1,20 @@
+# Place python module imports here, example:
+import os
+import matplotlib.pyplot as plt
+import act
+
+# Place arm username and token or example file if username and token
+# aren't set, example:
+username = os.getenv('ARM_USERNAME')
+token = os.getenv('ARM_PASSWORD')
+
+# Download and read file or files with the IO and discovery functions
+# within ACT, example:
+results = act.discovery.download_data(
+    username, token, 'sgpceilC1.b1', '2022-01-14', '2022-01-19')
+ceil_ds = act.io.armfiles.read_netcdf(results)
+
+# Plot file using the ACT display submodule, example:
+display = act.plotting.TimeSeriesDisplay(ceil_ds)
+display.plot('backscatter')
+plt.show()


Test patch:
Repository: ARM-DOE/ACT

Issue:
Change default behavior of datafilter
Currently the default behavior of act.qc.qcfilter.datafilter is to delete the qc_variable after applying QC but that could delete some valuable information if a user is exploring the data.  Recommend that we change the default to False.


Discussion:

Resolving patch:
diff --git a/act/qc/qcfilter.py b/act/qc/qcfilter.py
--- a/act/qc/qcfilter.py
+++ b/act/qc/qcfilter.py
@@ -951,7 +951,7 @@ def datafilter(
         rm_assessments=None,
         rm_tests=None,
         verbose=False,
-        del_qc_var=True,
+        del_qc_var=False,
     ):
         """
         Method to apply quality control variables to data variables by
@@ -981,7 +981,7 @@ def datafilter(
             the data values can not be determined after they are set to NaN
             and xarray method processing would also process the quality control
             variables, the default is to remove the quality control data
-            variables.
+            variables.  Defaults to False.
 
         Examples
         --------


Test patch:
diff --git a/act/tests/test_qc.py b/act/tests/test_qc.py
--- a/act/tests/test_qc.py
+++ b/act/tests/test_qc.py
@@ -789,7 +789,7 @@ def test_datafilter():
 
     ds.qcfilter.add_less_test(var_name, 99, test_assessment='Bad')
     ds_filtered = copy.deepcopy(ds)
-    ds_filtered.qcfilter.datafilter(rm_assessments='Bad', del_qc_var=False)
+    ds_filtered.qcfilter.datafilter(rm_assessments='Bad')
     ds_2 = ds_filtered.mean()
     assert np.isclose(ds_1[var_name].values, 98.86, atol=0.01)
     assert np.isclose(ds_2[var_name].values, 99.15, atol=0.01)
@@ -797,7 +797,7 @@ def test_datafilter():
     assert 'act.qc.datafilter' in ds_filtered[var_name].attrs['history']
 
     ds_filtered = copy.deepcopy(ds)
-    ds_filtered.qcfilter.datafilter(rm_assessments='Bad', variables=var_name)
+    ds_filtered.qcfilter.datafilter(rm_assessments='Bad', variables=var_name, del_qc_var=True)
     ds_2 = ds_filtered.mean()
     assert np.isclose(ds_2[var_name].values, 99.15, atol=0.01)
     expected_var_names = sorted(list(set(data_var_names + qc_var_names) - set(['qc_' + var_name])))
Repository: ARM-DOE/ACT

Issue:
Sunset Stamen maps in GeoDisplay and potentially replace
Stamen is transitioning their maps to stadia at the end of October 2023.  ACT will need to deprecate that feature in GeoDisplay and potentially look for replacements.

https://github.com/SciTools/cartopy/pull/2266 


Discussion:
Let's leave this open until the functionality stops working and we have to remove it.

Resolving patch:
diff --git a/act/plotting/geodisplay.py b/act/plotting/geodisplay.py
--- a/act/plotting/geodisplay.py
+++ b/act/plotting/geodisplay.py
@@ -61,7 +61,6 @@ def geoplot(
         img_tile=None,
         img_tile_args={},
         tile=8,
-        stamen='terrain-background',
         cartopy_feature=None,
         cmap='rainbow',
         text=None,
@@ -210,16 +209,9 @@ def geoplot(
         else:
             plt.title(title)
 
-        if stamen and img_tile is None:
-            tiler = img_tiles.Stamen(stamen)
+        if img_tile is not None:
+            tiler = getattr(img_tiles, img_tile)(**img_tile_args)
             ax.add_image(tiler, tile)
-            warnings.warn(
-                "Stamen is deprecated in Cartopy and in future versions of ACT, "
-                "please use img_tile to specify the image background. ")
-        else:
-            if img_tile is not None:
-                tiler = getattr(img_tiles, img_tile)(**img_tile_args)
-                ax.add_image(tiler, tile)
 
         colorbar_map = None
         if cmap is not None:


Test patch:
diff --git a/act/tests/test_plotting.py b/act/tests/test_plotting.py
--- a/act/tests/test_plotting.py
+++ b/act/tests/test_plotting.py
@@ -430,7 +430,6 @@ def test_geoplot():
             ],
             text={'Ponca City': [-97.0725, 36.7125]},
             img_tile=None,
-            stamen=None,
         )
         try:
             return geodisplay.fig
Repository: ARM-DOE/ACT

Issue:
Bug in xsection plot map code
* ACT version: Current Version
* Python version: All
* Operating System: All

### Description

xsection plot map is generating images with duplicate axes, see image below. I believe this is probably the cause to our baseline image failure.

![test_xsection_plot_map](https://github.com/ARM-DOE/ACT/assets/19153455/c644a2bf-f011-4f2f-a865-de8ca380db75)




Discussion:

Resolving patch:
diff --git a/act/plotting/xsectiondisplay.py b/act/plotting/xsectiondisplay.py
--- a/act/plotting/xsectiondisplay.py
+++ b/act/plotting/xsectiondisplay.py
@@ -75,6 +75,7 @@ def __init__(self, ds, subplot_shape=(1,), ds_name=None, **kwargs):
         super().__init__(ds, subplot_shape, ds_name, **kwargs)
 
     def set_subplot_to_map(self, subplot_index):
+        self.fig.delaxes(self.axes[subplot_index])
         total_num_plots = self.axes.shape
 
         if len(total_num_plots) == 2:
@@ -235,9 +236,9 @@ def plot_xsection(
             yc = y
 
         if x is None:
-            ax = my_dataarray.plot(ax=self.axes[subplot_index], **kwargs)
+            my_dataarray.plot(ax=self.axes[subplot_index], **kwargs)
         else:
-            ax = my_dataarray.plot(ax=self.axes[subplot_index], x=xc, y=yc, **kwargs)
+            my_dataarray.plot(ax=self.axes[subplot_index], x=xc, y=yc, **kwargs)
 
         the_coords = [the_keys for the_keys in my_dataarray.coords.keys()]
         if x is None:
@@ -255,7 +256,7 @@ def plot_xsection(
         yrng = self.axes[subplot_index].get_ylim()
         self.set_yrng(yrng, subplot_index)
         del temp_ds
-        return ax
+        return self.axes[subplot_index]
 
     def plot_xsection_map(
         self, dsname, varname, subplot_index=(0,), coastlines=True, background=False, **kwargs
@@ -290,7 +291,6 @@ def plot_xsection_map(
             raise ImportError(
                 'Cartopy needs to be installed in order to plot ' + 'cross sections on maps!'
             )
-
         self.set_subplot_to_map(subplot_index)
         self.plot_xsection(dsname, varname, subplot_index=subplot_index, **kwargs)
         xlims = self.xrng[subplot_index].flatten()


Test patch:
diff --git a/tests/plotting/baseline/test_xsection_plot_map.png b/tests/plotting/baseline/test_xsection_plot_map.png
Binary files a/tests/plotting/baseline/test_xsection_plot_map.png and b/tests/plotting/baseline/test_xsection_plot_map.png differ
Repository: ARM-DOE/ACT

Issue:
GeographicPlotDisplay documentation missing description of return value
* ACT version:  2.1.1
* Python version: all
* Operating System: all

### Description

The GeographicPlotDisplay is missing a description of the returned matplotlib axes object. This proved to be a bit confusing on how to tell a student how to adjust the axes limits on the GeographicPlotDisplay, since doing so depends on calling the methods of the returned matplotlib axes object.



Discussion:
@rcjackson Thanks for the heads up, I will work on a change for it! Wait nevermind I see you self assigned
@zssherman feel free to work on the quick fix if you have time
@rcjackson I do, will work on that now!
@rcjackson For clarification, so a return doc statement for the class itself or one of the plotting functions is missing it? Most of our classes in Py-ART and ACT don't have return docs, so trying to understand
I do see geoplot is missing a return

Resolving patch:
diff --git a/act/plotting/geodisplay.py b/act/plotting/geodisplay.py
--- a/act/plotting/geodisplay.py
+++ b/act/plotting/geodisplay.py
@@ -121,6 +121,11 @@ def geoplot(
             is made. See the matplotlib documentation for further details
             on what keyword arguments are available.
 
+        Returns
+        -------
+        ax : matplotlib axis handle
+            The matplotlib axis handle of the plot.
+
         """
         if dsname is None and len(self._ds.keys()) > 1:
             raise ValueError(


Test patch:
Repository: ARM-DOE/ACT

Issue:
AmeriFlux Documentation is not showing up in the API
The new act.io.ameriflux code is not showing up in the documentation.


Discussion:
@AdamTheisen I'll check it out and see if i can find the issue
@AdamTheisen Found it, in __init__ we are calling the function format_as_ameriflux but its called convert_to_ameriflux

Resolving patch:
diff --git a/act/io/__init__.py b/act/io/__init__.py
--- a/act/io/__init__.py
+++ b/act/io/__init__.py
@@ -28,7 +28,7 @@
             'check_if_tar_gz_file',
             'read_arm_mmcr',
         ],
-        'ameriflux': ['format_as_ameriflux'],
+        'ameriflux': ['convert_to_ameriflux'],
         'text': ['read_csv'],
         'icartt': ['read_icartt'],
         'mpl': ['proc_sigma_mplv5_read', 'read_sigma_mplv5'],


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
arrow key navigation in table widget
Hi. Good job with pyqtgraph!. I like it!.
According to the manual of pyqt: "You can navigate the cells in the table by clicking on a cell with the mouse, or by using the arrow keys. Because QTableView enables tabKeyNavigation by default, you can also hit Tab and Backtab to move from cell to cell.".

However, when I create a table in pyqtgraph, I cannot navigate with arrow keys. This is true even for the TableWidget example in pyqtgraph.

Do you know how to make this work without the need to handle key events?

Hanan.



Discussion:
It looks like `pg.TableWidget` catches Ctrl+c key press events but doesn't pass along others to the parent class (`QTableWidget`). I don't see a good reason for ignoring them, so I think it's a bug that should be fixed. Here's a workaround that should work for now:

``` python
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui

class MyTableWidget(pg.TableWidget):
    def keyPressEvent(self, event):
        pg.TableWidget.keyPressEvent(self, event)
        QtGui.QTableWidget.keyPressEvent(self, event)
```

As a side note, since you referred to the `QTableView` docs: be aware that `QTableView` and `QTableWidget` are different. _Widgets_ use the standard interface you're probably used to, whereas _Views_ are based on [model/view programming](http://doc.qt.io/qt-4.8/model-view-programming.html).


Resolving patch:
diff --git a/pyqtgraph/widgets/TableWidget.py b/pyqtgraph/widgets/TableWidget.py
--- a/pyqtgraph/widgets/TableWidget.py
+++ b/pyqtgraph/widgets/TableWidget.py
@@ -353,11 +353,11 @@ def contextMenuEvent(self, ev):
         self.contextMenu.popup(ev.globalPos())
         
     def keyPressEvent(self, ev):
-        if ev.text() == 'c' and ev.modifiers() == QtCore.Qt.ControlModifier:
+        if ev.key() == QtCore.Qt.Key_C and ev.modifiers() == QtCore.Qt.ControlModifier:
             ev.accept()
-            self.copy()
+            self.copySel()
         else:
-            ev.ignore()
+            QtGui.QTableWidget.keyPressEvent(self, ev)
 
     def handleItemChanged(self, item):
         item.itemChanged()


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Update functions.py
BUG: fix scaling with numpy 1.10

Crash with newest numpy 1.10
Pyqtgraph crashes with a TypeError in the [rescaleData function](https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/functions.py#L829) when using:
- Numpy 1.10
- Python 2.7

<sub>
TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
Traceback (most recent call last):
  File "/home/davidlp/miniconda/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ImageItem.py", line 309, in paint
    self.render()
  File "/home/davidlp/miniconda/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ImageItem.py", line 301, in render
    argb, alpha = fn.makeARGB(image.transpose((1, 0, 2)[:image.ndim]), lut=lut, levels=self.levels)
  File "/home/davidlp/miniconda/lib/python2.7/site-packages/pyqtgraph/functions.py", line 942, in makeARGB
    data = rescaleData(data, scale/(maxVal-minVal), minVal, dtype=int)
  File "/home/davidlp/miniconda/lib/python2.7/site-packages/pyqtgraph/functions.py", line 828, in rescaleData
    d2 *= scale
<sub>



Discussion:

A possible fix is to change [this line](https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/functions.py#L829) to:

d2 = np.multiply(d2, scale)

Another fix that works for me is:

```
d2 *= scale.astype(d2.dtype)
```


Resolving patch:
diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py
--- a/pyqtgraph/functions.py
+++ b/pyqtgraph/functions.py
@@ -826,7 +826,7 @@ def rescaleData(data, scale, offset, dtype=None):
         #p = np.poly1d([scale, -offset*scale])
         #data = p(data).astype(dtype)
         d2 = data-offset
-        d2 *= scale
+        np.multiply(d2, scale, out=d2, casting="unsafe")
         data = d2.astype(dtype)
     return data
     


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
ImageView fails to call its inherited close method
Same problem as #280.

```
diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py
index 61193fc..9d7ad2e 100644
--- a/pyqtgraph/imageview/ImageView.py
+++ b/pyqtgraph/imageview/ImageView.py
@@ -373,6 +373,7 @@ class ImageView(QtGui.QWidget):
         del self.image
         del self.imageDisp
         self.setParent(None)
+        QtGui.QWidget.close(self)

     def keyPressEvent(self, ev):
         #print ev.key()
```



Discussion:

Resolving patch:
diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py
--- a/pyqtgraph/imageview/ImageView.py
+++ b/pyqtgraph/imageview/ImageView.py
@@ -372,6 +372,7 @@ def close(self):
         self.scene.clear()
         del self.image
         del self.imageDisp
+        super(ImageView, self).close()
         self.setParent(None)
         
     def keyPressEvent(self, ev):
diff --git a/pyqtgraph/widgets/GraphicsView.py b/pyqtgraph/widgets/GraphicsView.py
--- a/pyqtgraph/widgets/GraphicsView.py
+++ b/pyqtgraph/widgets/GraphicsView.py
@@ -165,7 +165,8 @@ def close(self):
         self.sceneObj = None
         self.closed = True
         self.setViewport(None)
-        
+        super(GraphicsView, self).close()
+
     def useOpenGL(self, b=True):
         if b:
             if not HAVE_OPENGL:
diff --git a/pyqtgraph/widgets/PlotWidget.py b/pyqtgraph/widgets/PlotWidget.py
--- a/pyqtgraph/widgets/PlotWidget.py
+++ b/pyqtgraph/widgets/PlotWidget.py
@@ -69,7 +69,7 @@ def close(self):
         #self.scene().clear()
         #self.mPlotItem.close()
         self.setParent(None)
-        GraphicsView.close(self)
+        super(PlotWidget, self).close()
 
     def __getattr__(self, attr):  ## implicitly wrap methods from plotItem
         if hasattr(self.plotItem, attr):


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
invalid keyword argument 'range'
testing on Windows Qt5.5.1/ PyQtgraph github of 20160102, I have the following error on the "Custom Flowchart Nodes" test:

```
Using PyQt5 (default graphics system)
QWindowsWindow::setGeometryDp: Unable to set geometry 600x900+480+210 on QWidget
Window/'QMainWindowClassWindow'. Resulting geometry:  600x874+480+210 (frame: 8,
 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 69x69, maximum size: 1677721
5x16777215).
Using PyQt5 (default graphics system)
D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64\lib\sit
e-packages\pyqtgraph\flowchart\eq.py:11: FutureWarning: comparison to `None` wil
l result in an elementwise object comparison in the future.
  e = a==b
Traceback (most recent call last):
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\examples\FlowchartCustomNode.py", line 147, in <mod
ule>
    fNode = fc.createNode('UnsharpMask', pos=(0, 0))
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\flowchart\Flowchart.py", line 177, in createNode
    node = self.library.getNodeType(nodeType)(name)
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\examples\FlowchartCustomNode.py", line 106, in __in
it__
    CtrlNode.__init__(self, name, terminals=terminals)
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\flowchart\library\common.py", line 97, in __init__
    self.ui, self.stateGroup, self.ctrls = generateUi(ui)
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\flowchart\library\common.py", line 51, in generateU
i
    w.setOpts(**o)
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\widgets\SpinBox.py", line 160, in setOpts
    raise TypeError("Invalid keyword argument '%s'." % k)
TypeError: Invalid keyword argument 'range'.
```



Discussion:

Resolving patch:
diff --git a/examples/FlowchartCustomNode.py b/examples/FlowchartCustomNode.py
--- a/examples/FlowchartCustomNode.py
+++ b/examples/FlowchartCustomNode.py
@@ -92,8 +92,8 @@ class UnsharpMaskNode(CtrlNode):
     """Return the input data passed through an unsharp mask."""
     nodeName = "UnsharpMask"
     uiTemplate = [
-        ('sigma',  'spin', {'value': 1.0, 'step': 1.0, 'range': [0.0, None]}),
-        ('strength', 'spin', {'value': 1.0, 'dec': True, 'step': 0.5, 'minStep': 0.01, 'range': [0.0, None]}),
+        ('sigma',  'spin', {'value': 1.0, 'step': 1.0, 'bounds': [0.0, None]}),
+        ('strength', 'spin', {'value': 1.0, 'dec': True, 'step': 0.5, 'minStep': 0.01, 'bounds': [0.0, None]}),
     ]
     def __init__(self, name):
         ## Define the input / output terminals available on this node


Test patch: