Skip to content

Grts cell updates#491

Open
BryonLewis wants to merge 9 commits intomainfrom
grts-cell-updates
Open

Grts cell updates#491
BryonLewis wants to merge 9 commits intomainfrom
grts-cell-updates

Conversation

@BryonLewis
Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis commented Apr 20, 2026

Updates GRTS Cells

Background:

Initially the USGS had provided us with recording within the United States that had a GRTS_Cell_ID associated with them. This was a unique Id that indexes a 10kmX10km grid of the CONUS. You could use that to determine the location of a recording. I had created the GRTS Cell Model to include the cell_id as a primary key because I expected these to be unique values that could be used to index the locations. These GRTS Cell Ids can be loaded from shapefiles that are provided on sciencebase.gov.

Update:
There are multiple lists of GRTS_Cell_ids for different countries and regions that are not unique. They have something called a "Sample_Frame_ID" the sample_frame_id for CONUS is 14. So Canada and CONUS could have overlapping GRTS_cell_ids which means the primary key being relate dto the GRTS_cell_id doesn't work if you are loading multiple countries.

Issue:
To further add to the confusion, there is a shapefile for CONUS, and there is a shapefile for Alaska/Canada.
Alaska has a sample frame Id of 20 and Canada has a sample frame Id of 19. The shapefile that includes both Alaska and Canada doesn't differentiate between GRTS_cell_ids that are from Alaska or Canada, it's all one list of non-conflicting GRTS Cell Ids. So any recording from Canada or Alaska needs to look intot he same list of GRTS_cell_ids to get the proper cellId and the location associated with it.

PR Changes:

  • The GRTS Cell primary key has been changed to an autoincrement id because the pk being related to the GRTS Cell Id no longer makes sense when you have conflicting GRTS Cell Ids across regions (CONUS/Canda).
  • Updated the loadGRTS management script to have a --locations option that allows for loading other regions. For right now the only additional location that will loaded is Canada/Alaska using loadGRTS --locations 20
  • The loadGRTS management command will now replace any GRTS row that has a matching GRTS Cell Id and sample frame Id
  • Because Canada (sample frame id: 19) and Alaska (sample frame id: 20) use the same list of GRTS cellIds, which are imported as sample frame 20, there is a normalization function when using sample_frame_id that will auto convert 19 -> 20 whenever it is accessed.
  • All access to grts cell ids will now include a parameter for the sample frame id, which will default to 14 if none is provided. More details below about why this is done
  • Filename Processing:
    • There was some client-sidegu functionality to process filenames based on _ delimitation. This is taken from guano metadata file processing. The underscores separate and contain information like the GRTS_Cell_Id, could contain the sample_frame_id and a time. The consistency in the files aren't great, so there are a few edge cases where files can have different structured values. I.E sometimes the first number is a GRTS_cell_id and sometimes it is a sample frame_id.
    • I've refactored the filename metadata parsing into a utility function and added the processing of sample_frame_id to hopefully extract that if it exists.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 23, 2026

Deploying bats-ai with  Cloudflare Pages  Cloudflare Pages

Latest commit: 08a4246
Status: ✅  Deploy successful!
Preview URL: https://0a905410.bats-ai.pages.dev
Branch Preview URL: https://grts-cell-updates.bats-ai.pages.dev

View logs

@BryonLewis BryonLewis marked this pull request as ready for review April 24, 2026 13:23
@BryonLewis BryonLewis requested a review from naglepuff April 24, 2026 13:24
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