{"id":20630637,"url":"https://github.com/brookisme/tfr2human","last_synced_at":"2026-04-22T13:33:16.634Z","repository":{"id":57474883,"uuid":"215889441","full_name":"brookisme/tfr2human","owner":"brookisme","description":"easy parsing of Tensor Flow Records into dictionaries and numpy arrays","archived":false,"fork":false,"pushed_at":"2020-08-22T05:57:41.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-21T11:43:44.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brookisme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-17T21:34:18.000Z","updated_at":"2020-08-22T05:57:43.000Z","dependencies_parsed_at":"2022-09-10T02:23:18.027Z","dependency_job_id":null,"html_url":"https://github.com/brookisme/tfr2human","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/brookisme/tfr2human","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookisme%2Ftfr2human","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookisme%2Ftfr2human/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookisme%2Ftfr2human/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookisme%2Ftfr2human/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brookisme","download_url":"https://codeload.github.com/brookisme/tfr2human/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookisme%2Ftfr2human/sbom","scorecard":{"id":254508,"data":{"date":"2025-08-11","repo":{"name":"github.com/brookisme/tfr2human","commit":"1676e1536212114071d73fdec5701e0a77f6d64e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T09:19:04.658Z","repository_id":57474883,"created_at":"2025-08-17T09:19:04.658Z","updated_at":"2025-08-17T09:19:04.658Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32139386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T13:27:12.868Z","status":"ssl_error","status_checked_at":"2026-04-22T13:26:44.791Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T14:09:05.329Z","updated_at":"2026-04-22T13:33:16.605Z","avatar_url":"https://github.com/brookisme.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### TFR2Human\n\n_easy parsing of TFRecords_\n\n---\n\n#### INSTALL\n\n```bash\ngit clone https://github.com/brookisme/tfr2human.git\npip install -e tfr2human\n```\n\n---\n\n#### PARSER\n\nUsage (see complete [example below](#example)):\n\n```python\nTFR_LIST=\u003clist of paths to tfrecords\u003e\nFEATURE_PROPS=\u003cdictionary of properties and property types\u003e\nBANDS=\u003clist of band names or dict describing bands\u003e\nSIZE=\u003cDIMENSIONALITY OF BANDS\u003e\n\nparser=tfp.TFRParser(\n    TFR_LIST,\n    specs=FEATURE_PROPS,\n    band_specs=BANDS,\n    dims=[SIZE,SIZE])\n\nfor i,element in enumerate(parser.dataset)\n    ...\n    some_image=parser.image(element,bands=SOME_IM_BANDS,dtype=np.uint8)\n    some_data=parser.data(element,keys=SOME_KEYS)\n```\n\n\n---\n\n#### UTILS\n\nHere is a quick run down of the methods:\n\n* get_batches: break datasets into batches. \n    - this is different than TF's [batch](https://www.tensorflow.org/api_docs/python/tf/data/TFRecordDataset#batch) since it returns batches of datasets to be parsed rather than parsing a batch at a time.\n* image_profile: returns an image (rasterio) profile for a given lon/lat/crs/resolution/np.array\n* gcs_service: returns a google cloud storage client\n* save_to_gcs: save generic file to google cloud storage\n* csv/image_to_gcs: save csv/image to google cloud storage\n\n---\n\n\u003ca href='example'\u003e\u003c/a\u003e\n#### EXAMPLE\n\n```python\n#\n# CONFIG\n#\nNOISY=True\nNOISE_REDUCER=10\nRESOLUTION=20\nSIZE=384\nMIN_WATER_RATIO=0.005\nMAX_WATER_RATIO=0.96\nMAX_WATER_NO_DATA_COUNT=int((SIZE**2)*(0.25))\nMAX_S1_NAN_COUNT=int((SIZE**2)*(0.01))\nMAX_S1_ZERO_COUNT=int((SIZE**2)*(0.1))\n\nWATER_COLUMNS={\n    0: 'no_data_count',\n    1: 'not_water_count',\n    2: 'water_count'\n}\n\n\n#\n# TFR Feature Specs\n#\nWATER_BANDS=['water']\nS1_BANDS=['VV','VH','angle','VV_mean','VH_mean']\nBANDS=S1_BANDS+WATER_BANDS\n\nFEATURE_PROPS={\n    'tile_id': tf.string,\n    'crs': tf.string,\n    'year': tf.float32,\n    'month': tf.float32,\n    'lon': tf.float32,\n    'lat': tf.float32,\n    'x_offset': tf.float32,\n    'y_offset': tf.float32,\n    'biome_num': tf.float32,\n    'biome_name': tf.string,\n    'eco_id': tf.float32,\n    'eco_name': tf.string,\n    'grid': tf.string,\n    'grid_index': tf.int64\n    # 'nb_s1_images': tf.float32\n}\n```\n```python\n#\n# HELPERS\n#\ndef process_water(parser,element):\n  water=parser.image(element,bands=WATER_BANDS,dtype=np.uint8)\n  values,counts=np.unique(water,return_counts=True)\n  props={v: c for (v,c) in zip(values,counts)}\n  props={WATER_COLUMNS[i]: props.get(i,0) for i in range(3)}\n  water_ratio=props['water_count']/props['not_water_count']\n  props['water_ratio']=water_ratio\n  props['valid_water']=((MIN_WATER_RATIO\u003c=water_ratio) and \n            (water_ratio\u003cMAX_WATER_RATIO) and \n            (props['no_data_count']\u003cMAX_WATER_NO_DATA_COUNT))\n  return water, props\n\n\ndef process_s1(parser,element):\n  s1=parser.image(element,bands=S1_BANDS,dtype=np.float32)\n  props={ \n      's1_na_count': np.count_nonzero(np.isnan(s1)),\n      's1_zero_count': np.count_nonzero((s1[0]*s1[1])==0),\n  }\n  props['valid_s1']=((props['s1_na_count']\u003cMAX_S1_NAN_COUNT) and\n                     (props['s1_zero_count']\u003cMAX_S1_ZERO_COUNT))\n  return s1, props\n\n\ndef image_name(tile_id,year,month):\n  name=re.sub('S1','TILE',tile_id)\n  return f'{name}_{int(year)}{str(int(month)).zfill(2)}.tif'\n\n```\n\n```python\ndef run(parser,take=None,skip=0,batch_size=100):\n    \"\"\" example:\n        - parse all data properties (note: you could have also passed `keys` to `.data()` for a subset of properties )\n        - parse bands into distinct images\n    \"\"\"\n    parsed_data=parser.dataset.skip(skip)\n    if take:\n      parsed_data=parsed_data.take(take)\n    for batch_index, batch in utils.get_batches(parsed_data,batch_size=batch_size):\n      print('\\n'*2)\n      print('='*75)\n      print('BATCH:',batch_index)\n      print('='*75)\n      rows=[]\n      for i,element in enumerate(batch):\n          if NOISY and (not (i%NOISE_REDUCER)): \n              print(f'\\t- {i}...')\n          props=parser.data(element)\n          water, water_props=process_water(parser,element)\n          s1, s1_props=process_s1(parser,element)\n          props.update(water_props)\n          props.update(s1_props)\n          rows.append(props)\n          if props['valid_water'] and props['valid_s1']:\n              lon=props['lon']\n              lat=props['lat']\n              crs=props['crs']\n              name=image_name(props['tile_id'],props['year'],props['month'])\n              utils.image_to_gcs(\n                  s1,\n                  name,\n                  utils.image_profile(lon,lat,crs,RESOLUTION,s1),\n                  folder=f'{GCS_FOLDER}/S1',\n                  bucket=GCS_BUCKET)\n              utils.image_to_gcs(\n                  water,\n                  name,\n                  utils.image_profile(lon,lat,crs,RESOLUTION,water),\n                  folder=f'{GCS_FOLDER}/GSW',\n                  bucket=GCS_BUCKET)\n      df=pd.DataFrame(rows)\n      gcs_path=utils.csv_to_gcs(\n          df,\n          f'EXPORTS_BATCH-{batch_index}.csv',\n          folder=f'{GCS_FOLDER}/CSV',\n          bucket=GCS_BUCKET)\n      print('-'*75)\n      print(gcs_path)\n```\n\n```\nparser=tfp.TFRParser(\n    TFR_LIST,\n    specs=FEATURE_PROPS,\n    band_specs=BANDS,\n    dims=[SIZE,SIZE])\n\nrun(parser,take=TAKE,skip=SKIP,batch_size=BATCH_SIZE)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrookisme%2Ftfr2human","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrookisme%2Ftfr2human","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrookisme%2Ftfr2human/lists"}