package signals.JET;

import java.io.IOException;
import signals.Signal;
import descriptors.JET.JPFDesc;

/**
 * A JPF Signal. 1D and may have a time vector (coords in that dir)
 * 
 * @author oliford <codes@oliford.co.uk>
 */
public class JPF extends Signal {

	/** Create a new JPF with no tVector directly from data */
	public JPF(JPFDesc desc, Object data){
		super(data);
		this.desc = desc;
	}
	
	/** Create a new JPF (tVector) directly from data */
	public JPF(JPFDesc desc, Object data, Object tVec){
		super(data, new Object[]{ tVec });
		this.desc = desc;
	}
	
	/** Load a JPF Object from a HDF5 cache file */
	public JPF(String cacheRoot, JPFDesc desc) throws IOException {
		super(cacheRoot + desc.path() + ".hdf");
		this.desc = desc;
	}
		
	public JPF(int rank) {
		super(1); //JPFs are only ever 1D
	}
	
	/** Return vector of time coordinates */ 
	public final Object getTVector(){ return getCoords(0); }
	
	/** Return vector of time coordinates converted to given type */ 
	public final Object getTVectorAsType(Class<?> type){ return getCoordsAsType(0, type); }
	
	private JPFDesc desc;

	public JPFDesc getDescriptor() { return desc; }
	
	@Override
	public String toString() {
		return "JPF from '"+desc.toString()+"': " + super.toString();
	}
}
