Skip to content

Feature/propagatecompanionrecordvalue - #597

Open
samueljmcameron wants to merge 12 commits into
developfrom
feature/propagatecompanionrecordvalue
Open

samueljmcameron wants to merge 12 commits into
developfrom
feature/propagatecompanionrecordvalue

Conversation

@samueljmcameron

@samueljmcameron samueljmcameron commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a test file needed for https://github.com/JCSDA-internal/ufo/pull/4341. The file generation script is below.

Issue(s) addressed

Resolves #<issue_number>

Dependencies

List the other PRs that this PR is dependent on:

build-group=https://github.com/JCSDA-internal/ufo/pull/4341

Impact

Expected impact on downstream repositories: None

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have run the unit tests before creating the PR
# thanks to ReubenHill for sharing his code for generating nc4 files!
import numpy as np
import netCDF4 as nc
from datetime import datetime as dt, timezone as tz

outputname="obsfunction_propagateonevalueperrecord.nc4"

MISSING_FLOAT = -3.3687952621450501176e38  # jedi's missing float value
MISSING_STR = "MISSING*"  # jedi's missing string value
MISSING_DATETIME = 253281254337  # 23:58:57 on 29 February 9996
# missing int_64 is lowest possible int_64 value + 7
MISSING_INT64 = -(2**63) + 7
MISSING_INT = -2147483647

seqno = np.array([0,1,1,1,1,2,2])
Value = np.array([0.3,-4,3,2,1,100,0.2])
String = np.array(["here", "is", "a", "nice", "string", "with", "words"])
DerivedValue = np.array([0,1,2,3,4,5,6])
TestFirstValue = np.array([0.3,-4,-4,-4,-4,100,100])
TestDerivedFirstValue = np.array([33,0.5,0.5,0.5,0.5,-2.1,-2.1])
StartTime = int(dt(2018, 4, 14, 1, 0, 0, tzinfo=tz.utc).timestamp())

DateTime = np.array([StartTime] + [StartTime + i+10 for i in range(4)] + [StartTime+i+20 for i in range(2)])
TestStringLastValue = np.array(["here","string","string","string","string","words","words"])
TestDateTimeSecondValue = np.array([MISSING_DATETIME] + [StartTime + 11 for i in range(4)] + [StartTime+21 for i in range(2)])
TestDateTimeLastValue = np.array([StartTime] + [StartTime + 13 for i in range(4)] + [StartTime+21 for i in range(2)])


positiveFloatValue = np.array([1.99,1.01,1.01,1.01,1.01,1.99,1.99])
TestPositiveIntValueRound = np.array([2,1,1,1,1,2,2])
TestPositiveIntValueTruncate = np.array([1,1,1,1,1,1,1])

negativeFloatValue = -1*np.array([1.99,1.01,1.01,1.01,1.01,1.99,1.99])
TestNegativeIntValueRound = np.array([-2,-1,-1,-1,-1,-2,-2])
TestNegativeIntValueTruncate = np.array([-1,-1,-1,-1,-1,-1,-1])

Lat = np.array([0.0,5.0,5.0,5.0,5.0,20.0,20.0])
Lon = np.array([-30.0,0.0,0.0,0.0,0.0,30.0,30.0])

with nc.Dataset(outputname, "w", format="NETCDF4") as f:
    
    f.createDimension("Location", len(DateTime))



    lat_var = f.createVariable(
        "MetaData/latitude", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    lat_var[:] = Lat
    lon_var = f.createVariable(
        "MetaData/longitude", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    lon_var[:] = Lon
    datetime_var = f.createVariable(
        "MetaData/dateTime", "i8", ("Location"), fill_value=MISSING_DATETIME
    )
    datetime_var.units = "seconds since 1970-01-01T00:00:00Z"
    datetime_var[:] = DateTime

    seqno_var = f.createVariable(
        "MetaData/sequenceNumber", "i4", ("Location"), fill_value=MISSING_INT
    )
    seqno_var[:] = seqno

    sentence_var = f.createVariable(
        "MetaData/sentence", str, ("Location"), fill_value=MISSING_STR
    )
    sentence_var[:] = String

    obsvalue_var = f.createVariable(
        "ObsValue/Value", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    obsvalue_var[:] = Value

    derivedobsvalue_var = f.createVariable(
        "DerivedObsValue/Value", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    derivedobsvalue_var[:] = DerivedValue

    test1_var = f.createVariable(
        "MetaData/TestRef/FirstValue", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    test1_var[:] = TestFirstValue

    test2_var = f.createVariable(
        "MetaData/TestRef/DerivedFirstValue", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    test2_var[:] = TestDerivedFirstValue

    test_string_last_var = f.createVariable(
        "MetaData/TestRef/sentenceLastValue", str, ("Location"), fill_value=MISSING_STR
    )
    test_string_last_var[:] = TestStringLastValue

    test_datetime_second_var = f.createVariable(
        "MetaData/TestRef/dateTimeSecondValue", "i8", ("Location"), fill_value=MISSING_DATETIME
    )
    test_datetime_second_var[:] = TestDateTimeSecondValue

    test_datetime_last_var = f.createVariable(
        "MetaData/TestRef/dateTimeLastValue", "i8", ("Location"), fill_value=MISSING_DATETIME
    )
    test_datetime_last_var[:] = TestDateTimeLastValue


    positivefloat_var = f.createVariable(
        "MetaData/positiveFloatValue", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    positivefloat_var[:] = positiveFloatValue

    testpositiveintround_var = f.createVariable(
        "MetaData/TestRef/positiveIntValueRound", "i4", ("Location"), fill_value=MISSING_INT
    )
    testpositiveintround_var[:] = TestPositiveIntValueRound

    testpositiveinttruncate_var = f.createVariable(
        "MetaData/TestRef/positiveIntValueTruncate", "i4", ("Location"), fill_value=MISSING_INT
    )
    testpositiveinttruncate_var[:] = TestPositiveIntValueTruncate

    negativefloat_var = f.createVariable(
        "MetaData/negativeFloatValue", "f4", ("Location"), fill_value=MISSING_FLOAT
    )
    negativefloat_var[:] = negativeFloatValue

    testnegativeintround_var = f.createVariable(
        "MetaData/TestRef/negativeIntValueRound", "i4", ("Location"), fill_value=MISSING_INT
    )
    testnegativeintround_var[:] = TestNegativeIntValueRound

    testnegativeinttruncate_var = f.createVariable(
        "MetaData/TestRef/negativeIntValueTruncate", "i4", ("Location"), fill_value=MISSING_INT
    )
    testnegativeinttruncate_var[:] = TestNegativeIntValueTruncate

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The added fixture uses the repository’s established Git LFS convention and introduces no apparent code issues.

Pull request overview

Adds a Git LFS-backed NetCDF4 fixture for companion-record propagation tests.

Changes:

  • Adds the generated profile_obsfunction_propagatecompanionrecordvalue.nc4 test data file.
File summaries
File Description
testinput_tier_1/profile_obsfunction_propagatecompanionrecordvalue.nc4 Adds the LFS pointer for the new test fixture.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants