Skip to content

Add time series window#8

Merged
koldunovn merged 1 commit intomainfrom
add-time-series
Feb 7, 2026
Merged

Add time series window#8
koldunovn merged 1 commit intomainfrom
add-time-series

Conversation

@koldunovn
Copy link
Collaborator

New Files

  • src/interface/timeseries_popup.h - Header declaring init/show/cleanup for the time series popup
  • src/interface/timeseries_popup.c (~400 lines) - Non-modal popup window with custom XLib drawing:
    • "Nice numbers" tick algorithm for human-readable axis intervals
    • Y-axis with numeric tick labels (left margin 80px)
    • X-axis with CF time date formatting (if detected) or numeric labels
    • Light gray grid lines, blue data line (2px) with dots at data points
    • Gaps in line for fill/missing values
    • Deep-copies data for Expose redraws
    • Close button to dismiss

Modified Files

  1. src/ushow.defines.h - Added TSData struct (times, values, valid, title, axis labels)
  2. src/file_netcdf.h/c - Added netcdf_read_timeseries() and netcdf_read_timeseries_fileset() for single-point time series extraction (handles structured 2D and unstructured 1D, scale_factor/add_offset, fill values)
  3. src/file_zarr.h/c - Added zarr_read_timeseries() and zarr_read_timeseries_fileset() (reads per-timestep slices and extracts node value)
  4. src/interface/x_interface.h/c - Added MouseClickCallback, x_set_mouse_click_callback(), x_show_timeseries(), ButtonPress event handler on image widget, init/cleanup calls for timeseries popup
  5. src/ushow.c - Added on_mouse_click() handler that converts pixel→regrid→node, dispatches to correct reader, builds TSData, shows popup. Registered in main()
  6. Makefile - Added timeseries_popup.c to sources and dependency rules

Problem: When multiple files in a fileset have different time units (e.g., "seconds since 1850-01-01" in file 1, "seconds since 1851-01-01" in file 2), the raw time coordinate values were
concatenated without conversion. This made file 2's time=0 (meaning 1851-01-01) display as 1850-01-01 (file 0's epoch).

Fix: Added convert_time_units(value, src_units, dst_units) helper to both file_netcdf.c and file_zarr.c. It:

  1. Parses both CF time unit strings to extract the epoch and unit scale
  2. Converts the value to absolute seconds via the source epoch
  3. Converts back to the destination (file 0) units

This is now applied in 4 places:

  • netcdf_get_dim_info_fileset() — time step display labels
  • netcdf_read_timeseries_fileset() — time series plot X axis
  • zarr_get_dim_info_fileset() — zarr time step display labels
  • zarr_read_timeseries_fileset() — already used zarr_get_dim_info_fileset which is now fixed

  New Files

  - src/interface/timeseries_popup.h - Header declaring init/show/cleanup for the time series popup
  - src/interface/timeseries_popup.c (~400 lines) - Non-modal popup window with custom XLib drawing:
    - "Nice numbers" tick algorithm for human-readable axis intervals
    - Y-axis with numeric tick labels (left margin 80px)
    - X-axis with CF time date formatting (if detected) or numeric labels
    - Light gray grid lines, blue data line (2px) with dots at data points
    - Gaps in line for fill/missing values
    - Deep-copies data for Expose redraws
    - Close button to dismiss

  Modified Files

  1. src/ushow.defines.h - Added TSData struct (times, values, valid, title, axis labels)
  2. src/file_netcdf.h/c - Added netcdf_read_timeseries() and netcdf_read_timeseries_fileset() for single-point time series extraction (handles structured 2D and unstructured 1D,
  scale_factor/add_offset, fill values)
  3. src/file_zarr.h/c - Added zarr_read_timeseries() and zarr_read_timeseries_fileset() (reads per-timestep slices and extracts node value)
  4. src/interface/x_interface.h/c - Added MouseClickCallback, x_set_mouse_click_callback(), x_show_timeseries(), ButtonPress event handler on image widget, init/cleanup calls for
  timeseries popup
  5. src/ushow.c - Added on_mouse_click() handler that converts pixel→regrid→node, dispatches to correct reader, builds TSData, shows popup. Registered in main()
  6. Makefile - Added timeseries_popup.c to sources and dependency rules

 Problem: When multiple files in a fileset have different time units (e.g., "seconds since 1850-01-01" in file 1, "seconds since 1851-01-01" in file 2), the raw time coordinate values were
    concatenated without conversion. This made file 2's time=0 (meaning 1851-01-01) display as 1850-01-01 (file 0's epoch).

   Fix: Added convert_time_units(value, src_units, dst_units) helper to both file_netcdf.c and file_zarr.c. It:
   1. Parses both CF time unit strings to extract the epoch and unit scale
   2. Converts the value to absolute seconds via the source epoch
   3. Converts back to the destination (file 0) units

   This is now applied in 4 places:
   - netcdf_get_dim_info_fileset() — time step display labels
   - netcdf_read_timeseries_fileset() — time series plot X axis
   - zarr_get_dim_info_fileset() — zarr time step display labels
   - zarr_read_timeseries_fileset() — already used zarr_get_dim_info_fileset which is now fixed
@koldunovn koldunovn merged commit 0b380d2 into main Feb 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant