Skip to content

Commit

Permalink
Align projection time with null offset when delay is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Platone committed May 17, 2023
1 parent 9f97e6f commit c95527d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 57 deletions.
7 changes: 3 additions & 4 deletions vlbi/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ double VLBIBaseline::Correlate(int *indexes)
{
double val = 0.0;
int i = 0;
if(indexes[i] > 0 && indexes[i] < getNode(i)->getStream()->len) {
if(indexes[i] > 0 && indexes[i] < getNode(i)->getStream()->len)
val = getNode(i)->getStream()->buf[indexes[i]];
if(indexes[i] >= 0 && indexes[i] < getNode(i)->getStream()->len) {
val = getNode(i)->getStream()->buf[indexes[i]];
for(i = 1; i < nodes_count; i++)
if(indexes[i] > 0 && indexes[i] < getNode(i)->getStream()->len)
if(indexes[i] >= 0 && indexes[i] < getNode(i)->getStream()->len)
val = dsp_correlation_delegate(val, getNode(i)->getStream()->buf[indexes[i]]);
}
return val;
Expand Down
98 changes: 45 additions & 53 deletions vlbi/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void* fillplane(void *arg)
for(int y = 0; y < baselines->getCorrelationOrder(); y++) {
if(nodelay)
{
offsets[y] = 0.0;
offsets[y] = t;
}
else
{
Expand Down Expand Up @@ -501,21 +501,19 @@ void vlbi_set_baseline_buffer(void *ctx, const char **names, complex_t *buffer,
NodeCollection *nodes = (ctx != nullptr) ? (NodeCollection*)ctx : vlbi_nodes;
VLBIBaseline *b = nullptr;
BaselineCollection *collection = nodes->getBaselines();
char name[150] = "";
for(int x = 0; x < nodes->getBaselines()->Count(); x++) {
for(int y = 0; y < nodes->getCorrelationOrder(); y++) {
int idx = (x + y * (x / nodes->Count() +1)) % nodes->Count();
if(y == 0)
sprintf(name, "%s", names[idx]);
else
sprintf(name, "%s_%s", name, names[idx]);
}
if(collection->Contains(name)) {
b = collection->Get(name);
break;
int x = 0;
for(x = 0; x < collection->Count(); x++) {
b = collection->At(x);
int match = 0;
for(int y = 0; y < collection->getCorrelationOrder(); y++) {
for(int z = 0; z < collection->getCorrelationOrder(); z++) {
if(!strcmp(b->getNode(y)->getName(), names[z])) match ++;
}
}
if(match < collection->getCorrelationOrder()) continue;
break;
}
if(b == nullptr) return;
if(b == nullptr || x == collection->Count()) return;
dsp_stream_set_dim(b->getStream(), 0, len);
dsp_stream_alloc_buffer(b->getStream(), len);
b->getStream()->dft.pairs = buffer;
Expand All @@ -527,21 +525,19 @@ void vlbi_set_baseline_stream(void *ctx, const char **names, dsp_stream_p stream
NodeCollection *nodes = (ctx != nullptr) ? (NodeCollection*)ctx : vlbi_nodes;
VLBIBaseline *b = nullptr;
BaselineCollection *collection = nodes->getBaselines();
char name[150] = "";
for(int x = 0; x < nodes->getBaselines()->Count(); x++) {
for(int y = 0; y < nodes->getCorrelationOrder(); y++) {
int idx = (x + y * (x / nodes->Count() +1)) % nodes->Count();
if(y == 0)
sprintf(name, "%s", names[idx]);
else
sprintf(name, "%s_%s", name, names[idx]);
}
if(collection->Contains(name)) {
b = collection->Get(name);
break;
int x = 0;
for(x = 0; x < collection->Count(); x++) {
b = collection->At(x);
int match = 0;
for(int y = 0; y < collection->getCorrelationOrder(); y++) {
for(int z = 0; z < collection->getCorrelationOrder(); z++) {
if(!strcmp(b->getNode(y)->getName(), names[z])) match ++;
}
}
if(match < collection->getCorrelationOrder()) continue;
break;
}
if(b == nullptr) return;
if(b == nullptr || x == collection->Count()) return;
b->setStream(stream);
b->Lock();
}
Expand All @@ -551,21 +547,19 @@ dsp_stream_p vlbi_get_baseline_stream(void *ctx, const char **names)
NodeCollection *nodes = (ctx != nullptr) ? (NodeCollection*)ctx : vlbi_nodes;
VLBIBaseline *b = nullptr;
BaselineCollection *collection = nodes->getBaselines();
char name[150] = "";
for(int x = 0; x < nodes->getBaselines()->Count(); x++) {
for(int y = 0; y < nodes->getCorrelationOrder(); y++) {
int idx = (x + y * (x / nodes->Count() +1)) % nodes->Count();
if(y == 0)
sprintf(name, "%s", names[idx]);
else
sprintf(name, "%s_%s", name, names[idx]);
}
if(collection->Contains(name)) {
b = collection->Get(name);
break;
int x = 0;
for(x = 0; x < collection->Count(); x++) {
b = collection->At(x);
int match = 0;
for(int y = 0; y < collection->getCorrelationOrder(); y++) {
for(int z = 0; z < collection->getCorrelationOrder(); z++) {
if(!strcmp(b->getNode(y)->getName(), names[z])) match ++;
}
}
if(match < collection->getCorrelationOrder()) continue;
break;
}
if(b == nullptr) return nullptr;
if(b == nullptr || x == collection->Count()) return nullptr;
return b->getStream();
}

Expand All @@ -574,21 +568,19 @@ void vlbi_unlock_baseline(void *ctx, const char **names)
NodeCollection *nodes = (ctx != nullptr) ? (NodeCollection*)ctx : vlbi_nodes;
VLBIBaseline *b = nullptr;
BaselineCollection *collection = nodes->getBaselines();
char name[150] = "";
for(int x = 0; x < nodes->getBaselines()->Count(); x++) {
for(int y = 0; y < nodes->getCorrelationOrder(); y++) {
int idx = (x + y * (x / nodes->Count() +1)) % nodes->Count();
if(y == 0)
sprintf(name, "%s", names[idx]);
else
sprintf(name, "%s_%s", name, names[idx]);
}
if(collection->Contains(name)) {
b = collection->Get(name);
break;
int x = 0;
for(x = 0; x < collection->Count(); x++) {
b = collection->At(x);
int match = 0;
for(int y = 0; y < collection->getCorrelationOrder(); y++) {
for(int z = 0; z < collection->getCorrelationOrder(); z++) {
if(!strcmp(b->getNode(y)->getName(), names[z])) match ++;
}
}
if(match < collection->getCorrelationOrder()) continue;
break;
}
if(b == nullptr) return;
if(b == nullptr || x == collection->Count()) return;
b->Unlock();
}

Expand Down

0 comments on commit c95527d

Please sign in to comment.