Skip to content

subset_data point fails with TypeError #3258

Description

@samsrabin

Brief summary of bug

Trying to call subset_data point fails with a TypeError due to the Longitude type being used in an xarray sel() command.

General bug information

CTSM version you are using: ctsm5.3.056

Does this bug cause significantly incorrect results in the model's science? No

Configurations affected: n/a

Important details of your setup / configuration so we can reproduce the bug

On Derecho, can trigger like so:

tools/site_and_regional/subset_data point \
    --lat -24 --lon 31 --site sitename \
    --surf-year 2000 --lon-type 180 \
    --create-surface

Similar errors happen with the following instead of (just) --create-surface:

Important output or errors that show the problem

Error message:

Traceback (most recent call last):
  File "/glade/u/home/kwilcox/CTSM/tools/site_and_regional/./subset_data", line 37, in <module>
    main()
    ~~~~^^
  File "/glade/u/home/kwilcox/CTSM/tools/site_and_regional/../../python/ctsm/subset_data.py", line 885, in main
    subset_point(args, file_dict)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/glade/u/home/kwilcox/CTSM/tools/site_and_regional/../../python/ctsm/subset_data.py", line 723, in subset_point
    single_point.create_surfdata_at_point(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        file_dict["fsurf_dir"],
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        specify_fsurf_out=file_dict["fsurf_out"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/glade/u/home/kwilcox/CTSM/tools/site_and_regional/../../python/ctsm/site_and_regional/single_point_case.py", line 502, in create_surfdata_at_point
    f_tmp = f_in.sel(lsmlon=self.plon, lsmlat=self.plat, method="nearest")
  File "/glade/work/kwilcox/conda-envs/ctsm_pylib/lib/python3.13/site-packages/xarray/core/dataset.py", line 3249, in sel
    query_results = map_index_queries(
        self, indexers=indexers, method=method, tolerance=tolerance
    )
  File "/glade/work/kwilcox/conda-envs/ctsm_pylib/lib/python3.13/site-packages/xarray/core/indexing.py", line 195, in map_index_queries
    results.append(index.sel(labels, **options))
                   ~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/glade/work/kwilcox/conda-envs/ctsm_pylib/lib/python3.13/site-packages/xarray/core/indexes.py", line 765, in sel
    label_array = normalize_label(label, dtype=self.coord_dtype)
  File "/glade/work/kwilcox/conda-envs/ctsm_pylib/lib/python3.13/site-packages/xarray/core/indexes.py", line 545, in normalize_label
    value = np.asarray(value, dtype=dtype)
TypeError: float() argument must be a string or a real number, not 'Longitude'

Metadata

Metadata

Assignees

Labels

bugsomething is working incorrectlytest: pythonPass clm_pymods test suite plus Python sys/unit tests before merging

Type

Fields

No fields configured for Bug.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions