Repository: yt-project/yt

Issue:
EnzoSimulation fails when initial_time is used.
### Bug report

Creating an EnzoSimulation with `initial_time` fails with `UnboundLocalError: local variable 'my_initial_time' referenced before assignment`

Originally reported by Sam Patrick on [yt-users](https://mail.python.org/archives/list/yt-users@python.org/thread/MQWKNFM5QDESIYG3JN4D3LJPPFXW24I5/)

**Code for reproduction**

```python
import yt

es = yt.simulation("enzo_tiny_cosmology/32Mpc_32.enzo", "Enzo")
es.get_time_series(initial_time=(10.0, "Gyr"), final_time=(13.7, "Gyr"))
```

**Actual outcome**

<!--The output produced by the above code, which may be a screenshot, console
output, etc.-->

```
Traceback (most recent call last):
  File "bug.py", line 4, in <module>
    es.get_time_series(initial_time=(10.0, "Gyr"), final_time=(13.7, "Gyr"))
  File "yt/frontends/enzo/simulation_handling.py", line 282, in get_time_series
    my_initial_time.convert_to_units("s")
UnboundLocalError: local variable 'my_initial_time' referenced before assignment
```

**Expected outcome**

<!--A description of the expected outcome from the code snippet-->
<!--If this used to work in an earlier version of yt, please note the
version it used to work on-->

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Linux shakuras 4.15.0-1080-oem #90-Ubuntu
  * Python Version: Python 3.6.9 (default, Apr 18 2020, 01:56:04)
  * yt version: d9c898ae21c5e86c55831454d623e4c1a2539529




Discussion:

Resolving patch:
diff --git a/yt/frontends/enzo/simulation_handling.py b/yt/frontends/enzo/simulation_handling.py
--- a/yt/frontends/enzo/simulation_handling.py
+++ b/yt/frontends/enzo/simulation_handling.py
@@ -263,9 +263,9 @@ def get_time_series(self, time_data=True, redshift_data=True,
         else:
             if initial_time is not None:
                 if isinstance(initial_time, float):
-                    initial_time = self.quan(initial_time, "code_time")
+                    my_initial_time = self.quan(initial_time, "code_time")
                 elif isinstance(initial_time, tuple) and len(initial_time) == 2:
-                    initial_time = self.quan(*initial_time)
+                    my_initial_time = self.quan(*initial_time)
                 elif not isinstance(initial_time, YTArray):
                     raise RuntimeError(
                         "Error: initial_time must be given as a float or " +
@@ -277,14 +277,13 @@ def get_time_series(self, time_data=True, redshift_data=True,
 
             if final_time is not None:
                 if isinstance(final_time, float):
-                    final_time = self.quan(final_time, "code_time")
+                    my_final_time = self.quan(final_time, "code_time")
                 elif isinstance(final_time, tuple) and len(final_time) == 2:
-                    final_time = self.quan(*final_time)
+                    my_final_time = self.quan(*final_time)
                 elif not isinstance(final_time, YTArray):
                     raise RuntimeError(
                         "Error: final_time must be given as a float or " +
                         "tuple of (value, units).")
-                my_final_time = final_time.in_units("s")
             elif final_redshift is not None:
                 my_final_time = self.cosmology.t_from_z(final_redshift)
             else:


Test patch: