Skip to content

Commit

Permalink
Merge pull request #6 from jefferis/fix/datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferis authored Aug 5, 2024
2 parents 291b670 + bcc1f97 commit a90c003
Show file tree
Hide file tree
Showing 34 changed files with 173 additions and 3,598 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
^revdep$
^_pkgdown\.yml$
^docs$
^\.github$
^pkgdown$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
52 changes: 52 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
50 changes: 50 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
private/
.Rproj.user
.Rhistory
docs
9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ Authors@R: c(
Description: Provides function to read data from the 'Igor Pro' data analysis
program by Wavemetrics. The data formats supported are 'Igor' packed
experiment format (pxp) and 'Igor' binary wave (ibw). See:
https://www.wavemetrics.com/ for details. Also includes functions to load
<https://www.wavemetrics.com/> for details. Also includes functions to load
special pxp files produced by the 'Igor Pro' 'Neuromatic' and 'Nclamp'
packages for recording and analysing neuronal data. See
https://github.com/SilverLabUCL/NeuroMatic for details.
<https://github.com/SilverLabUCL/NeuroMatic> for details.
Imports:
bitops,
tools
tools,
timechange
Suggests:
spelling,
testthat
Expand All @@ -25,3 +26,5 @@ LazyLoad: yes
RoxygenNote: 7.3.2
Language: en-GB
Encoding: UTF-8
URL: https://github.com/jefferis/IgorR, https://jefferis.github.io/IgorR/
BugReports: https://github.com/jefferis/IgorR/issues
49 changes: 28 additions & 21 deletions R/ReadIgorBinary.R
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,16 @@ read.pxp<-function(pxpfile,regex,ReturnTimeSeries=FALSE,Verbose=FALSE,
i
}

igor_date_origin<-as.numeric(ISOdate(1904,1,1,hour=0,tz=""))

.convertIgorDate<-function(dateval){
dateval=dateval+igor_date_origin
class(dateval)<-"POSIXct"
dateval
# internal function to convert Igor dates
# these are expressed in seconds since 1904-01-01 in the local timezone
# note that we provide a tz argument to ensure that tests give the same
# results regardless of the local timezone of the test machine
.convertIgorDate<-function(dateval, tz=""){
igor_origin=ISOdatetime(1904,1,1,hour=0,min = 0, sec=0, tz=tz)
# this takes care of tz offset differences between the actual date and the origin
# e.g. because date is during daylight savings (but origin was not)
res=timechange::time_add(igor_origin, second = dateval)
res
}

# enum PackedFileRecordType {
Expand Down Expand Up @@ -402,24 +406,30 @@ NULL
x
}

# private function to read a null terminated string
.read_nt_string <- function(con, strlen) {
rawchars=readBin(con, what=raw(), n = strlen)
readBin(rawchars, what = 'character', n = 1)
}

.ReadPackedFile<-function(con, recordSize, encoding, Verbose){

# discard first header part
numBytes = 32
readChar(con, numBytes)
res=readBin(con, what=raw(), n = numBytes)
recordSize = recordSize - numBytes

# read the filename
file = list()
file$name = readChar(con, numBytes)
file$name = .read_nt_string(con, numBytes)
recordSize = recordSize - numBytes

# discard last header part
numBytes = 90
readChar(con, numBytes)
readBin(con, what = raw(), n = numBytes)
recordSize = recordSize - numBytes

file$data = .readCharsWithEnc(con, recordSize, encoding)
file$data = suppressWarnings(.readCharsWithEnc(con, recordSize, encoding))

if(nchar(file$data) <= 1) { # assume it is a formatted notebook with custom binary header

Expand Down Expand Up @@ -763,21 +773,18 @@ if(R.version$major>2) {
attr(WaveData,"Note")=.readCharsWithEnc(con,BinHeader5$noteSize,encoding)
}

if(BinHeader5$dataEUnitsSize>0) {
attr(WaveData,"dataUnits")=.readNullTermString(con,BinHeader5$dataEUnitsSize,encoding)
}
# ignore dataEUnitsSize
if(BinHeader5$dataEUnitsSize>0)
readBin(con,what=raw(), n = BinHeader5$dataEUnitsSize)

if(any(BinHeader5$dimEUnitsSize>0))
readBin(con,what=raw(), n = sum(BinHeader5$dimEUnitsSize))

if(any(BinHeader5$dimEUnitsSize>0)) {
x=.readCharsWithEnc(con,BinHeader5$dimEUnitsSize,encoding)
attr(WaveData,"dimUnits")[BinHeader5$dimEUnitsSize>0]=x[BinHeader5$dimEUnitsSize>0]
}
# Trim units down to active dimensions
attr(WaveData,"dimUnits")=attr(WaveData,"dimUnits")[WaveHeader5$nDim>0]

if(any(BinHeader5$dimLabelsSize>0)) {
x=.readCharsWithEnc(con,BinHeader5$dimLabelsSize,encoding)
attr(WaveData,"dimLabels")=x[WaveHeader5$nDim>0]
}
if(any(BinHeader5$dimLabelsSize>0))
readBin(con,what=raw(), n = sum(BinHeader5$dimLabelsSize))

# Finish up
# Re-dimension
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# IgorR
<!-- badges: start -->
[![DOI](https://img.shields.io/badge/doi-10.5281%2Fzenodo.10230-blue.svg)](http://dx.doi.org/10.5281/zenodo.10230)
[![Release Version](https://img.shields.io/github/release/jefferis/IgorR.svg)](https://github.com/jefferis/IgorR/releases/latest)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/IgorR)](https://cran.r-project.org/package=IgorR)
[![Build Status](https://travis-ci.org/jefferis/IgorR.svg?branch=master)](https://travis-ci.org/jefferis/IgorR)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/IgorR)](https://cran.r-project.org/package=IgorR)
[![R-CMD-check](https://github.com/jefferis/IgorR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jefferis/IgorR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->


Introduction
============
Expand Down
3 changes: 3 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
url: https://jefferis.github.io/IgorR/
template:
bootstrap: 5
reference:
- title: Package Help
contents:
Expand Down
140 changes: 0 additions & 140 deletions docs/404.html

This file was deleted.

Loading

0 comments on commit a90c003

Please sign in to comment.