diff --git a/.nojekyll b/.nojekyll index 3743be6..d72a71d 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -3e7206df \ No newline at end of file +b16a9076 \ No newline at end of file diff --git a/mod_data-disc.html b/mod_data-disc.html index 2c62b63..492a36b 100644 --- a/mod_data-disc.html +++ b/mod_data-disc.html @@ -370,6 +370,7 @@

On this page

  • Panel Discussion
  • Data Repositories
  • General Data Searches
  • +
  • Data Inventory Value
  • Downloading Data
  • Data format and structure
  • Additional Resources @@ -576,25 +577,27 @@

    Search Operators

    + + +
    +

    Data Inventory Value

    +

    Documenting potential datasets (and their metadata) thoroughly in a data inventory provides numerous benefits! These include:

    +
    -Data Inventory Value +Activity: Data Inventory
    -

    Documenting potential datasets (and their metadata) thoroughly in a data inventory provides numerous benefits! These include:

    -
      -
    • Well-documented datasets make it easier for researchers to find and access specific data for reproducible research
    • -
    • Documentation will help researchers to quickly understand the context, scope, and limitations of the data, reducing the time spent on preliminary data assessment
    • -
    • Detailed documentation will speed up the data publication process (e.g., data provenance, the difference among methods, etc.)
    • -
    • When you need to generate metadata for your own synthesis data product you’ll already have much of the information you need
    • -
    -
    -

    Activity: Data Inventory

    Part 1 (~25 min)

    In your project groups:

      @@ -620,7 +623,6 @@

      Activity: Data Inv
    • Do you agree with the information entered in the data inventory?
    • Is there any information you think should be in the data inventory that wasn’t?
    -
    @@ -642,7 +644,6 @@

    Activity: Data Inv

    -

    Downloading Data

    Once you’ve found data, filled out your data inventory, and decided which datasets you actually want, it’s time to download some of them! There are several methods you can use and it’s possible that each won’t work in all cases so it’s important to be at least somewhat familiar with several of these tools.

    @@ -840,7 +841,7 @@

    Downloading Data

    -Activity: Data Download +Activity: Data Download (~25 mins)
    @@ -853,7 +854,7 @@

    Downloading Data

  • Write a script for your group to download data using your chosen method
  • Zoom rooms for each download method will be available. You are encouraged to join the room that corresponds to your chosen method to discuss with others working on the same approach.
      -
    • If no datasets in your group’s inventory need the download method you chose, try to run the example code included below
    • +
    • If no datasets in your group’s inventory need the download method you chose, try to run the example codes provided
  • @@ -864,24 +865,26 @@

    Data format and

    CSV and TXT are common formats for data storage. In addition, formats like NetCDF, HDF5, Matlab, and Rdata/RDS are frequently used in research, along with spatial datasets such as geotiff, shapefiles, and raster files (refer to the spatial module for more details).

    In the R environment, data structure are typically checked using the following functions.

    -
    library(dplyr)
    -
    -# Define URL as an object
    -dt_url <- "https://pasta.lternet.edu/package/data/eml/knb-lter-sbc/77/10/f32823fba432f58f66c06b589b7efac6" 
    -
    -# Read it into R
    -lobster_df <- read.csv(file = dt_url,na=-99999)
    -
    -# Check the structure of the data
    -head(lobster_df)
    -
    -summary(lobster_df)
    +
    # Load needed packages
    +## install.packages("librarian")
    +librarian::shelf(tidyverse)
    +
    +# Define URL as an object
    +dt_url <- "https://pasta.lternet.edu/package/data/eml/knb-lter-sbc/77/10/f32823fba432f58f66c06b589b7efac6" 
    +
    +# Read it into R
    +lobster_df <- read.csv(file = dt_url,na=-99999)
    +
    +# Check the structure of the data
    +head(lobster_df)
     
    -str(lobster_df)
    +summary(lobster_df)
     
    -glimpse(lobster_df)
    +str(lobster_df)
     
    -anyNA(lobster_df)
    +glimpse(lobster_df) + +anyNA(lobster_df)

    diff --git a/search.json b/search.json index 0e962da..ac5470d 100644 --- a/search.json +++ b/search.json @@ -73,7 +73,18 @@ "href": "mod_data-disc.html#general-data-searches", "title": "Data Discovery & Management", "section": "General Data Searches", - "text": "General Data Searches\nIf you don’t find what you’re looking for in a particular data repository (or want to look for data not included in one of those platforms), you might want to consider a broader search. For instance, Google is a suprisingly good resource for finding data and–for those familiar with Google Scholar for peer reviewed literature-specific Googling–there is a dataset-specific variant of Google called Google Dataset Search.\n\nSearch Operators\nVirtually all search engines support “operators” to create more effective queries (i.e., search parameters). If you don’t use operators, most systems will just return results that have any of the words in your search which is non-ideal, especially when you’re looking for very specific criteria in candidate datasets.\nSee the tabs below for some useful operators that might help narrow your dataset search even when using more general platforms.\n\nQuotesWildcardPlusORMinusSiteFile TypeIn TitleIn URL\n\n\nUse quotation marks (\"\") to search for an exact phrase. This is particularly useful when you need specific data points or exact wording.\nExample: \"reef biodiversity\"\n\n\nUse an asterisk (*) to search using a placeholder for any word or phrase in the query. This is useful for finding variations of a term.\nExample: Pinus * data\n\n\nUse a plus sign (+) to search using more than one query at the same time. This is useful when you need combinations of criteria to be met.\nExample: bat + cactus\n\n\nUse the ‘or’ operator (OR) operator to search for either one term or another. It broadens your search to include multiple terms.\nExample: \"prairie pollinator\" OR \"grassland pollinator\"\n\n\nUse a minus sign (-; a.k.a. “hyphen”) to exclude certain words from your search. Useful to filter out irrelevant results.\nExample: marine biodiversity data -fishery\n\n\nUse the site operator (site:) to search within a specific website or domain. This is helpful when you’re looking for data from a particular source.\nExample: site:.gov bird data\n\n\nUse the file type operator (filetype:) to search for data with a specific file extension. Useful to make sure the data you find is already in a format you can intteract with.\nExample: filetype:tif precipitation data\n\n\nUse the ‘in title’ operator (intitle:) to search for pages that have a specific word in the title. This can narrow down your results to more relevant pages.\nExample: intitle:\"lithology\"\n\n\nUse the ‘in URL’ operator (inurl:) to search for pages that have a specific word in the URL. This can help locate data repositories or specific datasets.\nExample: inurl:data soil chemistry\n\n\n\n\n\n\n\n\n\nData Inventory Value\n\n\n\nDocumenting potential datasets (and their metadata) thoroughly in a data inventory provides numerous benefits! These include:\n\nWell-documented datasets make it easier for researchers to find and access specific data for reproducible research\nDocumentation will help researchers to quickly understand the context, scope, and limitations of the data, reducing the time spent on preliminary data assessment\nDetailed documentation will speed up the data publication process (e.g., data provenance, the difference among methods, etc.)\nWhen you need to generate metadata for your own synthesis data product you’ll already have much of the information you need\n\n\nActivity: Data Inventory\nPart 1 (~25 min)\nIn your project groups:\n\nReview your data inventory Google Sheet and discuss why you chose the datasets included.\nDecide on a number of datasets equal to the number of group members. Each group member will self-assign one dataset.\n\nLater, each person will download their assigned dataset\n\nDiscuss what key information is needed to determine if each dataset is useful for your project.\nOnce you’ve identified the necessary information, start completing the detailed data inventory Google Sheet (tab separated by project groups).\n\nThis sheet will be shared with another group later\n\n\nPart 2 (~10 min)\n\nSwap data inventory tables with another project group.\nEach group member self-assigns one dataset from the other group’s inventory.\n\nBe sure to choose from the more detailed second sheet!\n\nTry to find the exact data file to which you were assigned\nDo you agree with the information entered in the data inventory?\nIs there any information you think should be in the data inventory that wasn’t?\n\n\n\n\n\n\n\n\n\n\nDiscussion: Data Inventory\n\n\n\nReturn to the main room and let’s discuss (some of) the following questions:\n\nWhich elements of the data inventory table made it easier or more difficult to find the data?\nWhat challenges did you encounter while searching for the datasets?\nWhat is your plan for downloading the data?", + "text": "General Data Searches\nIf you don’t find what you’re looking for in a particular data repository (or want to look for data not included in one of those platforms), you might want to consider a broader search. For instance, Google is a suprisingly good resource for finding data and–for those familiar with Google Scholar for peer reviewed literature-specific Googling–there is a dataset-specific variant of Google called Google Dataset Search.\n\nSearch Operators\nVirtually all search engines support “operators” to create more effective queries (i.e., search parameters). If you don’t use operators, most systems will just return results that have any of the words in your search which is non-ideal, especially when you’re looking for very specific criteria in candidate datasets.\nSee the tabs below for some useful operators that might help narrow your dataset search even when using more general platforms.\n\nQuotesWildcardPlusORMinusSiteFile TypeIn TitleIn URL\n\n\nUse quotation marks (\"\") to search for an exact phrase. This is particularly useful when you need specific data points or exact wording.\nExample: \"reef biodiversity\"\n\n\nUse an asterisk (*) to search using a placeholder for any word or phrase in the query. This is useful for finding variations of a term.\nExample: Pinus * data\n\n\nUse a plus sign (+) to search using more than one query at the same time. This is useful when you need combinations of criteria to be met.\nExample: bat + cactus\n\n\nUse the ‘or’ operator (OR) operator to search for either one term or another. It broadens your search to include multiple terms.\nExample: \"prairie pollinator\" OR \"grassland pollinator\"\n\n\nUse a minus sign (-; a.k.a. “hyphen”) to exclude certain words from your search. Useful to filter out irrelevant results.\nExample: marine biodiversity data -fishery\n\n\nUse the site operator (site:) to search within a specific website or domain. This is helpful when you’re looking for data from a particular source.\nExample: site:.gov bird data\n\n\nUse the file type operator (filetype:) to search for data with a specific file extension. Useful to make sure the data you find is already in a format you can intteract with.\nExample: filetype:tif precipitation data\n\n\nUse the ‘in title’ operator (intitle:) to search for pages that have a specific word in the title. This can narrow down your results to more relevant pages.\nExample: intitle:\"lithology\"\n\n\nUse the ‘in URL’ operator (inurl:) to search for pages that have a specific word in the URL. This can help locate data repositories or specific datasets.\nExample: inurl:data soil chemistry", + "crumbs": [ + "Phase I -- Prepare", + "Data Discovery" + ] + }, + { + "objectID": "mod_data-disc.html#data-inventory-value", + "href": "mod_data-disc.html#data-inventory-value", + "title": "Data Discovery & Management", + "section": "Data Inventory Value", + "text": "Data Inventory Value\nDocumenting potential datasets (and their metadata) thoroughly in a data inventory provides numerous benefits! These include:\n\nWell-documented datasets make it easier for researchers to find and access specific data for reproducible research\nDocumentation will help researchers to quickly understand the context, scope, and limitations of the data, reducing the time spent on preliminary data assessment\nDetailed documentation will speed up the data publication process (e.g., data provenance, the difference among methods, etc.)\nWhen you need to generate metadata for your own synthesis data product you’ll already have much of the information you need\n\n\n\n\n\n\n\nActivity: Data Inventory\n\n\n\nPart 1 (~25 min)\nIn your project groups:\n\nReview your data inventory Google Sheet and discuss why you chose the datasets included.\nDecide on a number of datasets equal to the number of group members. Each group member will self-assign one dataset.\n\nLater, each person will download their assigned dataset\n\nDiscuss what key information is needed to determine if each dataset is useful for your project.\nOnce you’ve identified the necessary information, start completing the detailed data inventory Google Sheet (tab separated by project groups).\n\nThis sheet will be shared with another group later\n\n\nPart 2 (~10 min)\n\nSwap data inventory tables with another project group.\nEach group member self-assigns one dataset from the other group’s inventory.\n\nBe sure to choose from the more detailed second sheet!\n\nTry to find the exact data file to which you were assigned\nDo you agree with the information entered in the data inventory?\nIs there any information you think should be in the data inventory that wasn’t?\n\n\n\n\n\n\n\n\n\nDiscussion: Data Inventory\n\n\n\nReturn to the main room and let’s discuss (some of) the following questions:\n\nWhich elements of the data inventory table made it easier or more difficult to find the data?\nWhat challenges did you encounter while searching for the datasets?\nWhat is your plan for downloading the data?", "crumbs": [ "Phase I -- Prepare", "Data Discovery" @@ -84,7 +95,7 @@ "href": "mod_data-disc.html#downloading-data", "title": "Data Discovery & Management", "section": "Downloading Data", - "text": "Downloading Data\nOnce you’ve found data, filled out your data inventory, and decided which datasets you actually want, it’s time to download some of them! There are several methods you can use and it’s possible that each won’t work in all cases so it’s important to be at least somewhat familiar with several of these tools.\nMost of these methods will work regardless of the format of the data (i.e., its file extension) but the format of the data will be important when you want to ‘read in’ the data and begin to work with it.\nBelow are some example code chunks for five methods of downloading data in a scripted way. There will be contexts where only a Graphical User Interface (“GUI”; [GOO-ee]) is available but the details of that method of downloading are usually specific to the portal you’re accessing so we won’t include an artificial general case.\n\nData Entity URLR PackageBatch DownloadAPI CallCommand Line\n\n\nSometimes you might have a URL directly to a particular dataset (usually one hosted by a data repository). If you copy/paste this URL into your browser the download would automatically begin. However, we want to make our workflows entirely scripted (or close to it) so see the example below for how to download data via a data entity URL.\nThe dataset we download below is one collected at the Santa Barbara Coastal (SBC) LTER on California spiny lobster (Panulirus interruptus) populations.\n\n# Define URL as an object\n1dt_url <- \"https://pasta.lternet.edu/package/data/eml/knb-lter-sbc/77/10/f32823fba432f58f66c06b589b7efac6\"\n\n# Read it into R\nlobster_df <- read.csv(file = dt_url)\n\n\n1\n\nYou can typically find this URL in the repository where you found the dataset\n\n\n\n\n\n\nIf you’re quite lucky, the data you want might be stored in a repository that developed (and maintains!) an R package. These packages may or may not be on CRAN (packages can often also be found on GitHub or Bioconductor). Typically these packages have a “vignette” that demonstrates how their functions should be used.\nConsider the following example adapted from the USGS dataRetrieval package vignette. Visit USGS National Water Dashboard interactive map to find site numbers and check data availability.\n\n# Load needed packages\n## install.packages(\"librarian\")\nlibrarian::shelf(dataRetrieval)\n\n# Set up the parameters for the Santa Ynez River site\nsiteNumber <- \"11133000\" # USGS site number for Santa Ynez River at Narrows\nparameterCd <- \"00060\" # Parameter code for discharge (cubic feet per second)\nstartDate <- \"2024-01-01\" # Start date\nendDate <- \"2024-01-31\" # End date\n\n# Retrieve daily discharge data\ndischargeData <- readNWISdv(siteNumber, parameterCd, startDate, endDate)\n\n# View the first few rows of the data\nhead(dischargeData)\n\n\n\nYou may want to download several data files hosted in the same repository online for different spatial/temporal replicates. You could try to use the data entity URL or an associated package (if one exists) or you could write code to do a “batch download” where you’d just download each file using a piece of code that repeats itself as much as needed.\nThe dataset we demonstrate downloading below is NOAA weather station data. Specifically it is the Integrated Surface Data (ISD).\n\n# Specify the start/end years for which you want to download data\ntarget_years <- 2000:2005\n\n# Loop across years\nfor(focal_year in target_years){\n\n # Message a progress note\n1 message(\"Downloading data for \", focal_year)\n\n # Assemble the URL manually\n2 focal_url <- paste0( \"https://www1.ncdc.noaa.gov/pub/data/gsod/\", focal_year, \"/gsod_\", focal_year, \".tar\")\n\n # Assemble your preferred file name once it's downloaded\n3 focal_file <- paste0(\"gsod_\", focal_year, \".tar\")\n\n # Download the data\n utils::download.file(url = focal_url, destfile = focal_file, method = \"curl\")\n}\n\n\n1\n\nThis message isn’t required but can be nice! Downloading data can take a long time so including a progress message can re-assure you that your R session hasn’t crashed\n\n2\n\nTo create a working URL you’ll likely need to click an example data file URL and try to exactly mimic its format\n\n3\n\nThis step again isn’t required but can let you exert a useful level of control over the naming convention of your data file(s)\n\n\n\n\n\n\nIn slightly more complicated contexts, you’ll need to make a request via an Application Programming Interface (“API”). As the name might suggest, these platforms serve as a bridge between some application and code. Using such a method to download data is a–relatively–frequent occurrence in synthesis work.\nHere we’ll demonstrate an API call for NOAA’s Tides and Currents data.\n\n# Load needed packages\n## install.packages(\"librarian\")\nlibrarian::shelf(httr, jsonlite)\n\n# Define a 'custom function' to fetch desired data\n1fetch_tide <- function(station_id, product = \"predictions\", datum = \"MLLW\", time_zone = \"lst_ldt\", units = \"english\", interval = \"h\", format = \"json\"){\n\n2 # Custom error flags\n\n # Get a few key dates (relative to today)\n yesterday <- Sys.Date() - 1\n two_days_from_now <- Sys.Date() + 2\n\n # Adjust begin/end dates\n begin_date <- format(yesterday, \"%Y%m%d\")\n end_date <- format(two_days_from_now, \"%Y%m%d\")\n \n # Construct the API URL\n3 tide_url <- paste0(\n \"https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?\",\n \"product=\", product,\n \"&application=NOS.COOPS.TAC.WL\",\n \"&begin_date=\", begin_date,\n \"&end_date=\", end_date,\n \"&datum=\", datum,\n \"&station=\", station_id,\n \"&time_zone=\", time_zone,\n \"&units=\", units,\n \"&interval=\", interval,\n \"&format=\", format)\n\n # Make the API request\n response <- httr::GET(url = tide_url)\n \n # If the request is successful...\n if(httr::status_code(response) == 200){\n \n # Parse the JSON response\n tide_data <- jsonlite::fromJSON(httr::content(response, \"text\", encoding = \"UTF-8\"))\n\n # And return it\n return(tide_data)\n\n # Otherwise...\n } else {\n\n # Pass the error message back to the user\n stop(\"Failed to fetch tide data\\nStatus code: \", httr::status_code(response))\n\n }\n}\n\n# Invoke the function\ntide_df <- fetch_tide(station_id = \"9411340\")\n\n\n1\n\nWhen you do need to make an API call, a custom function is a great way of standardizing your entries. This way you only need to figure out how to do the call once and from then on you can lean on the (likely more familiar) syntax of the language in which you wrote the function!\n\n2\n\nWe’re excluding error checks for simplicity’s sake but you will want to code informative error checks. Basically you want to consider inputs to the function that would break it and pre-emptively stop the function (with an informative message) when those malformed inputs are received\n\n3\n\nJust like the batch download, we need to assemble the URL that the API is expecting\n\n\n\n\n\n\nWhile many ecologists are trained in programming languages like R or Python, some operations require the Command Line Interface (“CLI”; a.k.a. “shell”, “bash”, “terminal”, etc.). Don’t worry if you’re new to this language! There are a lot of good resources for learning the fundamentals, including The Carpentries’ workshop “The Unix Shell”.\nBelow we demonstrate download via command line for NASA OMI/Aura Sulfur Dioxide (SO2). The OMI science team produces this Level-3 Aura/OMI Global OMSO2e Data Products (0.25 degree Latitude/Longitude grids) for atmospheric analysis.\n\nStep 1: Using the “subset/Get Data” tab on the right-hand side of the data page, generate a list of file names for your specified target area and time period. Download the list of links as a TXT file named “list.txt”. Be sure to document the target area and temporal coverage you selected in your data inventory table.\n\n\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0802_v003-2023m0804t120832.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0805_v003-2023m0807t093718.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0806_v003-2023m0809t092629.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0807_v003-2023m0809t092635.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0808_v003-2023m0810t092721.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0809_v003-2023m0811t101920.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\n\n\nStep 2: Open a command line window and execute the wget command. Replace the placeholder for username and password with your EarthData login credentials.\n\n\nwget -nc --load-cookies ..\\.urs_cookies --save-cookies ..\\.urs_cookies --keep-session-cookies --user=XXX --password=XXX\n--content-disposition -i list.txt\n\n\nIf you encounter any issue, follow this step-by-step guide on using wget and curl specifically with the GES DISC data system.\n\n\n\n\n\n\n\n\n\n\nActivity: Data Download\n\n\n\n\nEach member work on the data that you have been assigned.\nDiscuss with your group how to collaborate on coding without creating merge conflicts\n\nMany right answers here so discuss the pros/cons of each and pick one that feels best for your group!\n\nWrite a script for your group to download data using your chosen method\nZoom rooms for each download method will be available. You are encouraged to join the room that corresponds to your chosen method to discuss with others working on the same approach.\n\nIf no datasets in your group’s inventory need the download method you chose, try to run the example code included below", + "text": "Downloading Data\nOnce you’ve found data, filled out your data inventory, and decided which datasets you actually want, it’s time to download some of them! There are several methods you can use and it’s possible that each won’t work in all cases so it’s important to be at least somewhat familiar with several of these tools.\nMost of these methods will work regardless of the format of the data (i.e., its file extension) but the format of the data will be important when you want to ‘read in’ the data and begin to work with it.\nBelow are some example code chunks for five methods of downloading data in a scripted way. There will be contexts where only a Graphical User Interface (“GUI”; [GOO-ee]) is available but the details of that method of downloading are usually specific to the portal you’re accessing so we won’t include an artificial general case.\n\nData Entity URLR PackageBatch DownloadAPI CallCommand Line\n\n\nSometimes you might have a URL directly to a particular dataset (usually one hosted by a data repository). If you copy/paste this URL into your browser the download would automatically begin. However, we want to make our workflows entirely scripted (or close to it) so see the example below for how to download data via a data entity URL.\nThe dataset we download below is one collected at the Santa Barbara Coastal (SBC) LTER on California spiny lobster (Panulirus interruptus) populations.\n\n# Define URL as an object\n1dt_url <- \"https://pasta.lternet.edu/package/data/eml/knb-lter-sbc/77/10/f32823fba432f58f66c06b589b7efac6\"\n\n# Read it into R\nlobster_df <- read.csv(file = dt_url)\n\n\n1\n\nYou can typically find this URL in the repository where you found the dataset\n\n\n\n\n\n\nIf you’re quite lucky, the data you want might be stored in a repository that developed (and maintains!) an R package. These packages may or may not be on CRAN (packages can often also be found on GitHub or Bioconductor). Typically these packages have a “vignette” that demonstrates how their functions should be used.\nConsider the following example adapted from the USGS dataRetrieval package vignette. Visit USGS National Water Dashboard interactive map to find site numbers and check data availability.\n\n# Load needed packages\n## install.packages(\"librarian\")\nlibrarian::shelf(dataRetrieval)\n\n# Set up the parameters for the Santa Ynez River site\nsiteNumber <- \"11133000\" # USGS site number for Santa Ynez River at Narrows\nparameterCd <- \"00060\" # Parameter code for discharge (cubic feet per second)\nstartDate <- \"2024-01-01\" # Start date\nendDate <- \"2024-01-31\" # End date\n\n# Retrieve daily discharge data\ndischargeData <- readNWISdv(siteNumber, parameterCd, startDate, endDate)\n\n# View the first few rows of the data\nhead(dischargeData)\n\n\n\nYou may want to download several data files hosted in the same repository online for different spatial/temporal replicates. You could try to use the data entity URL or an associated package (if one exists) or you could write code to do a “batch download” where you’d just download each file using a piece of code that repeats itself as much as needed.\nThe dataset we demonstrate downloading below is NOAA weather station data. Specifically it is the Integrated Surface Data (ISD).\n\n# Specify the start/end years for which you want to download data\ntarget_years <- 2000:2005\n\n# Loop across years\nfor(focal_year in target_years){\n\n # Message a progress note\n1 message(\"Downloading data for \", focal_year)\n\n # Assemble the URL manually\n2 focal_url <- paste0( \"https://www1.ncdc.noaa.gov/pub/data/gsod/\", focal_year, \"/gsod_\", focal_year, \".tar\")\n\n # Assemble your preferred file name once it's downloaded\n3 focal_file <- paste0(\"gsod_\", focal_year, \".tar\")\n\n # Download the data\n utils::download.file(url = focal_url, destfile = focal_file, method = \"curl\")\n}\n\n\n1\n\nThis message isn’t required but can be nice! Downloading data can take a long time so including a progress message can re-assure you that your R session hasn’t crashed\n\n2\n\nTo create a working URL you’ll likely need to click an example data file URL and try to exactly mimic its format\n\n3\n\nThis step again isn’t required but can let you exert a useful level of control over the naming convention of your data file(s)\n\n\n\n\n\n\nIn slightly more complicated contexts, you’ll need to make a request via an Application Programming Interface (“API”). As the name might suggest, these platforms serve as a bridge between some application and code. Using such a method to download data is a–relatively–frequent occurrence in synthesis work.\nHere we’ll demonstrate an API call for NOAA’s Tides and Currents data.\n\n# Load needed packages\n## install.packages(\"librarian\")\nlibrarian::shelf(httr, jsonlite)\n\n# Define a 'custom function' to fetch desired data\n1fetch_tide <- function(station_id, product = \"predictions\", datum = \"MLLW\", time_zone = \"lst_ldt\", units = \"english\", interval = \"h\", format = \"json\"){\n\n2 # Custom error flags\n\n # Get a few key dates (relative to today)\n yesterday <- Sys.Date() - 1\n two_days_from_now <- Sys.Date() + 2\n\n # Adjust begin/end dates\n begin_date <- format(yesterday, \"%Y%m%d\")\n end_date <- format(two_days_from_now, \"%Y%m%d\")\n \n # Construct the API URL\n3 tide_url <- paste0(\n \"https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?\",\n \"product=\", product,\n \"&application=NOS.COOPS.TAC.WL\",\n \"&begin_date=\", begin_date,\n \"&end_date=\", end_date,\n \"&datum=\", datum,\n \"&station=\", station_id,\n \"&time_zone=\", time_zone,\n \"&units=\", units,\n \"&interval=\", interval,\n \"&format=\", format)\n\n # Make the API request\n response <- httr::GET(url = tide_url)\n \n # If the request is successful...\n if(httr::status_code(response) == 200){\n \n # Parse the JSON response\n tide_data <- jsonlite::fromJSON(httr::content(response, \"text\", encoding = \"UTF-8\"))\n\n # And return it\n return(tide_data)\n\n # Otherwise...\n } else {\n\n # Pass the error message back to the user\n stop(\"Failed to fetch tide data\\nStatus code: \", httr::status_code(response))\n\n }\n}\n\n# Invoke the function\ntide_df <- fetch_tide(station_id = \"9411340\")\n\n\n1\n\nWhen you do need to make an API call, a custom function is a great way of standardizing your entries. This way you only need to figure out how to do the call once and from then on you can lean on the (likely more familiar) syntax of the language in which you wrote the function!\n\n2\n\nWe’re excluding error checks for simplicity’s sake but you will want to code informative error checks. Basically you want to consider inputs to the function that would break it and pre-emptively stop the function (with an informative message) when those malformed inputs are received\n\n3\n\nJust like the batch download, we need to assemble the URL that the API is expecting\n\n\n\n\n\n\nWhile many ecologists are trained in programming languages like R or Python, some operations require the Command Line Interface (“CLI”; a.k.a. “shell”, “bash”, “terminal”, etc.). Don’t worry if you’re new to this language! There are a lot of good resources for learning the fundamentals, including The Carpentries’ workshop “The Unix Shell”.\nBelow we demonstrate download via command line for NASA OMI/Aura Sulfur Dioxide (SO2). The OMI science team produces this Level-3 Aura/OMI Global OMSO2e Data Products (0.25 degree Latitude/Longitude grids) for atmospheric analysis.\n\nStep 1: Using the “subset/Get Data” tab on the right-hand side of the data page, generate a list of file names for your specified target area and time period. Download the list of links as a TXT file named “list.txt”. Be sure to document the target area and temporal coverage you selected in your data inventory table.\n\n\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0802_v003-2023m0804t120832.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0805_v003-2023m0807t093718.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0806_v003-2023m0809t092629.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0807_v003-2023m0809t092635.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0808_v003-2023m0810t092721.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\nhttps://acdisc.gesdisc.eosdis.nasa.gov/opendap/HDF-EOS5/ncml/Aura_OMI_Level3/OMSO2e.003/2023/OMI-Aura_L3-OMSO2e_2023m0809_v003-2023m0811t101920.he5.ncml.nc4?ColumnAmountSO2[119:659][0:1439],lat[119:659],lon[0:1439]\n\n\nStep 2: Open a command line window and execute the wget command. Replace the placeholder for username and password with your EarthData login credentials.\n\n\nwget -nc --load-cookies ..\\.urs_cookies --save-cookies ..\\.urs_cookies --keep-session-cookies --user=XXX --password=XXX\n--content-disposition -i list.txt\n\n\nIf you encounter any issue, follow this step-by-step guide on using wget and curl specifically with the GES DISC data system.\n\n\n\n\n\n\n\n\n\n\nActivity: Data Download (~25 mins)\n\n\n\n\nEach member work on the data that you have been assigned.\nDiscuss with your group how to collaborate on coding without creating merge conflicts\n\nMany right answers here so discuss the pros/cons of each and pick one that feels best for your group!\n\nWrite a script for your group to download data using your chosen method\nZoom rooms for each download method will be available. You are encouraged to join the room that corresponds to your chosen method to discuss with others working on the same approach.\n\nIf no datasets in your group’s inventory need the download method you chose, try to run the example codes provided", "crumbs": [ "Phase I -- Prepare", "Data Discovery" @@ -95,7 +106,7 @@ "href": "mod_data-disc.html#data-format-and-structure", "title": "Data Discovery & Management", "section": "Data format and structure", - "text": "Data format and structure\nCSV and TXT are common formats for data storage. In addition, formats like NetCDF, HDF5, Matlab, and Rdata/RDS are frequently used in research, along with spatial datasets such as geotiff, shapefiles, and raster files (refer to the spatial module for more details).\nIn the R environment, data structure are typically checked using the following functions.\n\nlibrary(dplyr)\n\n# Define URL as an object\ndt_url <- \"https://pasta.lternet.edu/package/data/eml/knb-lter-sbc/77/10/f32823fba432f58f66c06b589b7efac6\" \n\n# Read it into R\nlobster_df <- read.csv(file = dt_url,na=-99999)\n\n# Check the structure of the data\nhead(lobster_df)\n\nsummary(lobster_df)\n\nstr(lobster_df)\n\nglimpse(lobster_df)\n\nanyNA(lobster_df)", + "text": "Data format and structure\nCSV and TXT are common formats for data storage. In addition, formats like NetCDF, HDF5, Matlab, and Rdata/RDS are frequently used in research, along with spatial datasets such as geotiff, shapefiles, and raster files (refer to the spatial module for more details).\nIn the R environment, data structure are typically checked using the following functions.\n\n# Load needed packages\n## install.packages(\"librarian\")\nlibrarian::shelf(tidyverse)\n\n# Define URL as an object\ndt_url <- \"https://pasta.lternet.edu/package/data/eml/knb-lter-sbc/77/10/f32823fba432f58f66c06b589b7efac6\" \n\n# Read it into R\nlobster_df <- read.csv(file = dt_url,na=-99999)\n\n# Check the structure of the data\nhead(lobster_df)\n\nsummary(lobster_df)\n\nstr(lobster_df)\n\nglimpse(lobster_df)\n\nanyNA(lobster_df)", "crumbs": [ "Phase I -- Prepare", "Data Discovery" diff --git a/sitemap.xml b/sitemap.xml index 7c932c2..d1be2ca 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,110 +2,110 @@ https://lter.github.io/ssecr/policy_conduct.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/policy_pronouns.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/mod_data-disc.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_data-viz.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_version-control.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/mod_next-steps.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_facilitation.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/policy_ai.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/index.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.810Z https://lter.github.io/ssecr/instructors.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.810Z https://lter.github.io/ssecr/mod_wrangle.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/proj_milestones.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/mod_findings.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/fellows.html - 2024-10-01T23:13:32.240Z + 2024-10-01T23:29:30.791Z https://lter.github.io/ssecr/mod_credit.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.810Z https://lter.github.io/ssecr/mod_project-mgmt.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_reproducibility.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_stats.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/mod_team-sci.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/mod_reports.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_thinking.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/policy_usability.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/mod_interactivity.html - 2024-10-01T23:13:32.260Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/mod_spatial.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.811Z https://lter.github.io/ssecr/proj_teams.html - 2024-10-01T23:13:32.262Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/policy_attendance.html - 2024-10-01T23:13:32.261Z + 2024-10-01T23:29:30.812Z https://lter.github.io/ssecr/CONTRIBUTING.html - 2024-10-01T23:13:32.216Z + 2024-10-01T23:29:30.767Z