Sivaji Posted August 9 Share Posted August 9 I'm using spy.pull to pull the data however I need to resample the signal based on another signal before I pull the data. I see pushing the resampled signal and pulling is an alternative option, I was wondering if there is a way to pass in another signal in the 'calculation' since I've to repeat this for a lot of signals. for the above code, for 'calculation' I've to use '$signal.resample($signalKeySource)' . I've SEEQ ID for the $signalKeySource, not sure how can I reference this in the 'calculation'. There is something like formula parameters for spy.push, not sure about the equivalent in spy.pull. Link to comment Share on other sites More sharing options...
Solution Thorsten Vogt Posted August 9 Solution Share Posted August 9 Hi Sivaji, I don't think it is possible to add another signal to the calculation argument. One way would be pushing new signals that do the resampling to Seeq and pulling the data as you mentioned. Another way might be using the API instead. The following code runs a formula and transforms the result into a DataFrame. The results of the run_formula method must be parsed to a dictionary, as the datatype of each entry is of type seeq.sdk.models.sample_output_v1.SampleOutputV1. from seeq import sdk import pandas as pd signal1_id = "A925A450-CCF2-43E5-8342-0623DD650270" signal2_id = "3A7B47C8-A45D-4615-9758-B93A8136AF0F" apiClient = spy.client formulasApi = sdk.FormulasApi(apiClient) result = formulasApi.run_formula(start = "2024-07-01T00:00:00Z", end = "2024-07-02T00:00:00Z", formula = "$signal1.resample($signal2)", parameters = [f"signal1={signal1_id}", f"signal2={signal2_id}"]) dict_list = [entry.to_dict() for entry in result.samples.samples] df = pd.DataFrame(dict_list) df['key'] = pd.to_datetime(df['key'], unit='ns', utc=True) df.set_index('key', inplace=True) df.drop(columns=['is_uncertain'], inplace=True) Nevertheless, I think the preferred way would be creating signals in Seeq that do the resampling and pull the values from these signals. An example of creating calculated items in Seeq can be found here: Regards, Thorsten 1 Link to comment Share on other sites More sharing options...
Sivaji Posted August 13 Author Share Posted August 13 Thanks @Thorsten Vogt, this is working fine but limiting the datapoints by 1000. Are we limited to 1000 datapoints when we use api? Is there a way to change this setting without admin access? Link to comment Share on other sites More sharing options...
Thorsten Vogt Posted August 14 Share Posted August 14 Hi Sivaji, you can either change the limit parameter in the run_formula function to a higher value or use a contination token to run subsequent queries on the data: from seeq import sdk import pandas as pd signal1_id = "A925A450-CCF2-43E5-8342-0623DD650270" signal2_id = "3A7B47C8-A45D-4615-9758-B93A8136AF0F" apiClient = spy.client formulasApi = sdk.FormulasApi(apiClient) token = '' while True: result = formulasApi.run_formula(start = "2024-06-01T23:00:00Z", end = "2024-07-02T00:00:00Z", formula = "$signal1.resample($signal2)", parameters = [f"signal1={signal1_id}", f"signal2={signal2_id}"], continuation_token = token) dict_list = [entry.to_dict() for entry in result.samples.samples] if (token == ''): df = pd.DataFrame(dict_list) else: df = pd.concat([df,pd.DataFrame(dict_list)]) token = result.samples.continuation_token if token == None: break df['key'] = pd.to_datetime(df['key'], unit='ns', utc=True) df.set_index('key', inplace=True) df.drop(columns=['is_uncertain'], inplace=True) Regards, Thorsten 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now